0

I am just starting out Godot and I need a little help with some platforming code written in Godot 4

How do I set a default value to this -> @export var speed:int: set = set_speed

The language being used in the code is gdscript

100k7gm
  • 25
  • 4

1 Answers1

1

Generally, we write the setters and getters on a separate line

@export var speed: int:
    set = set_speed

And now this looks like an ordinary variable declaration, followed by some modifiers. We can put the initial value exactly where we would for a variable that didn't have custom accessors: after the type.

@export var speed: int = 0:
    set = set_speed
Silvio Mayolo
  • 62,821
  • 6
  • 74
  • 116