Godot Tutorial Space L3

This commit is contained in:
Torsten 2024-02-27 16:32:53 +01:00
parent d8b6323dee
commit 6a0d25a16a
2 changed files with 21 additions and 0 deletions

View file

@ -1,16 +0,0 @@
Sprite2D node
F => focus view on object
To get type information in code auto-completion, go to _Editor -> Editor Settings_, and in the _Text Editor -> Completion_ section, turn on the checkbox named _Add Type Hints_. You can also search for "type hints" in the search bar at the top of the window to find it quickly.
`Vector2` values have a function named `angle()` that calculates and returns the vector's angle in radians. If we assign that to the ship's rotation, it will turn to face its move direction.
```gdscript
var velocity = Vector2(480, -480)
func _process(delta: float) -> void:
position += velocity * delta
rotation = velocity.angle()
````