Godot Version
Godot 4.3
Question
When I turn to 12 o’clock and press in front, I fly in front. But when I turn 3 o’clock and press in front, I’m not flying for 3 hours, but for 1.5 hours. I want it to turn from 12 o’clock to 3 o’clock.
extends CharacterBody2D
@export var speed = 400
@export var rotation_speed: float = 0.8
var max_speed = 500
var rotation_direction: float = 0.0
var forward_input = 0
var forward_direction = Vector2.UP
func get_input():
rotation_direction = Input.get_axis("ui_left", "ui_right")
forward_input = Input.get_axis("ui_down", "ui_up")
func _process(delta):
get_input()
if rotation_direction != 0:
rotation += rotation_direction * rotation_speed * delta
forward_direction = Vector2.UP.rotated(rotation)
if forward_input != 0:
velocity += forward_direction * forward_input * speed * delta
print(position)
print(velocity)
print(rotation)
move_and_slide()