Parser Error: Unexpected "Identifier" in class body

Godot Version

`i think i use godo v4_3

Question

Parser Error: Unexpected “Identifier” in class body. it error and my code is correct … i think so why i can’t use 2 const (text on strong) ? (sorry for my english =

extends Node2D

const lightTexture = preload(“res://JPG BAZARD/Light.png”)
const GRID_SIZE = 16

onready var fog = $fog

var display_width = ProjectSettings.get(“display/window/size/viewport_width”)
var display_height = ProjectSettings.get(“display/window/size/viewport_height”)

var fogimage = image.new()
var fogtexture = ImageTexture.new()
var lightImage = lightTexture.get_data()
var light_offest = Vector2(lightTexture.get_width()/2, lightTexture.get_height()/2)

func _ready() → void:
var fog_image_width = display_width/GRID_SIZE
var fog_image_height = display_height/GRID_SIZE
fogimage.create(fog_image_width, fog_image_height, false, Image.FORMAT_RGBAH)
fogimage.fill(color.black)
lightImage.convert(Image.FORMAT_RGBAH)
fog.scale *= GRID_SIZE

func update_fog(new_grid_position):
fogimage.lock()
lightImage.lock()

var light_rect = Rect2(Vector2.ZERO, Vector2(lightImage.get_width(), lightImage.get_height()))
fogimage.blend_rect(lightImage, light_rect, new_grid_position - light_offest)
fogimage.unlock()
lightImage.unlock()
update_fog_image_texture()

func update_fog_image_texture():
fogtexture.create_from_image(fogimage)
fog.texture = fogtexture

func _input(event):
update_fog(get_local_mouse_position()/GRID_SIZE)

The correct Godot 4.x syntax is @onready var fog = $fog

2 Likes