facsimile-wing/test_rotation.gd

25 lines
805 B
GDScript

extends Area2D
# Simple test to verify rotation behavior
var test_angle: float = 0.0
var rotate_to_velocity: bool = true
func _process(delta):
# Move in a straight line at 100 pixels per second
var move_x = cos(deg_to_rad(test_angle)) * 100 * delta
var move_y = sin(deg_to_rad(test_angle)) * 100 * delta
position.x += move_x
position.y += move_y
# Rotate to face movement direction (this is the key fix)
if rotate_to_velocity:
var velocity = Vector2(cos(deg_to_rad(test_angle)) * 100, sin(deg_to_rad(test_angle)) * 100)
rotation = velocity.angle()
# Debug output
print("Test angle: ", test_angle, "Velocity angle:", velocity.angle(), "Rotation set to:", rotation)
func _ready():
# Set initial rotation for testing
test_angle = 0.0