What is the difference? My autocomplete for unhandled_input and physics_process gives me this:
Why are we adding this?
func _unhandled_input(event: InputEvent) -> void:
I mean, ": InputEvent" and "-> void" parts. Why?
Well, I already searched for an answer here in the Functions section. BUT I got two new questions. Hope you can help me.
Why we need to specify the InputEvent for the argument event and the float for the argument delta? Isn't it a default for newer versions of Godot?
And, why are we specifying the return type of each function? What happens if we don't write the "-> void" part of the function?
These are optional type hints: https://docs.godotengine.org/en/latest/getting_started/scripting/gdscript/static_typing.html
Using them helps catch (many) more errors and bugs than with dynamic code, it makes your code more self-documenting, making it easier to work with over time. Finally, with future versions of the gdscript compiler, you should benefit from major performance improvements with type hints.