obsidian/MyObsidianVault/Godot_Training/2D/Tutorial Game - to space and beyond/2024-02-17.md
2024-02-17 08:28:19 +01:00

662 B

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.

var velocity = Vector2(480, -480)

func _process(delta: float) -> void:
  position += velocity * delta
  rotation = velocity.angle()