spacegame/player/player.gd
2025-02-28 17:55:52 +01:00

16 lines
561 B
GDScript

extends RigidBody2D
class_name Player
@export var thruster_strength := 40.0
@export var rotation_strnegth := 500.0
func _physics_process(delta: float) -> void:
var input := Vector2(Input.get_action_strength("left") - Input.get_action_strength("right"), Input.get_action_strength("front") - Input.get_action_strength("back"))
apply_central_impulse(Vector2.DOWN.rotated(rotation) * thruster_strength * delta * input.y)
apply_torque_impulse(input.x * rotation_strnegth * delta)
if input.y < 0:
%thruster.active = true
else:
%thruster.active = false