16 lines
662 B
Markdown
16 lines
662 B
Markdown
|
|
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()
|
||
|
|
````
|