+2 votes

Hello, when I try to export a var in 4.0 with the syntax

export(float) var velocity

export(NodePath) var targetnode1

I get the error

Unexpected "Identifier" in class body.

full class code

extends KinematicBody3D

export(float) var velocity
export(NodePath) var targetnode1

func _ready():
pass

func onNavigationAgent3Dnavigationfinished():
pass # Replace with function body.

Godot version 4.0
in Engine by (14 points)

1 Answer

+6 votes

In 4.0 you need to use annotations combined with typing:

@export
var velocity: float

@export
var target_node_1: NodePath 

See the docs on annotations and exports for more info:

Notice that you need to look at the docs for "latest" instead of "3.2" down in the bottom left of the docs.

by (1,519 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.