19 lines
481 B
GDScript
19 lines
481 B
GDScript
extends CharacterBody2D
|
|
|
|
@export var speed = 25
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _physics_process(delta):
|
|
var sprite = self.get_child(1)
|
|
self.velocity = Vector2(cos(sprite.get_rotation() - PI / 2), sin(sprite.get_rotation() - PI / 2)).normalized() * speed
|
|
|
|
|
|
if self.move_and_slide():
|
|
sprite.rotate(PI)
|
|
|
|
|