Unexpected identifier in class body

Following instructions from tutorial for top down movement and got that error message, my code looks like this:

Movement where the character rotates and moves forward or backward.

extends CharacterBody2D

Movement speed in pixels per second.

export var speed := 500

Rotation speed in radians per second.

export var angular_speed := 5.0

func _physics_process(delta):
# See how we’re using Input.get_action_strength() to calculate the direction we rotate.
# The value will be in the [-1.0, 1.0] range.
var rotate_direction := Input.get_action_strength(“Turn Right”) - Input.get_action_strength(“Turn Left”)
rotation += rotate_direction * angular_speed * delta
# Below, we calculate the forward or backward move direction and directly multiply it to calculate a velocity.
# transform.y stores the node’s local axes, allowing us to move it in the direction it’s currently facing.
var velocity := (Input.get_action_strength(“Turn Around”) - Input.get_action_strength(“Walk”)) * transform.y * speed
move_and_slide(velocity)

“extends CharacterBody2d” and “export var speed := 500” are where the error message pops up.

Hello, few things

Can you please share with us what tutorial and format your code?

You can format your code with the format code button and pasting it there or 3 back ticks above and below it (```)

It’s a lot easier to tell what’s going on and read your code when you do, thanks!

You’re missing an “@” before the export keyword


And as said in the last commentary, please format your code when posting, make easier to read, select all your code text and click on this:

image

1 Like