When I follow a tutorial, the callback function in the tutorial would look like this: func physics_process(delta) while mine would look like this: func physics_process(delta: float) -> void:
What are those float and void for and why are they here?
When I follow a tutorial, the callback function in the tutorial would look like this: func physics_process(delta) while mine would look like this: func physics_process(delta: float) -> void:
What are those float and void for and why are they here?
You are using typed scripting, the documentation you are reading likely isn't. Might be the version of documentation you are following is for an older version, or has not been updated with typed scripting in mind. Don't worry though, dynamic and typed GDScript can be mixed.
It's only important that you understand what statically typed script is: https://docs.godotengine.org/en/3.1/getting_started/scripting/gdscript/static_typing.html https://godotengine.org/article/optional-typing-gdscript
I see. The tutorial I'm following is for Godot 3.2 and I have 3.2.1 version so I didn't expect it to be that different.
Wait by typed scripting you mean things like GDscript, C#, etc as opposed to visual script? The tutorial teaches GDscript, not visual script
No, typed scripting as in statically typed, as in the type of each variable, function, etc., are explicitly defined by your code. Eventually that way of coding will be used for more optimized script runtime. In your case, the return value of "process" is explicitly typed as void
, and the type of the variable "delta" is defined as a float
.
Void means the function doesn't return anything.
Correct. :)
Editor Settings > Text Editor > Completion > Add Type Hints
auto-completion example:
type hints off: func _process(delta):
type hints on: func _process(delta: float) -> void: