19 lines
564 B
GDScript3
19 lines
564 B
GDScript3
|
|
extends RigidBody2D
|
||
|
|
|
||
|
|
@export var thrust_power : float = 1
|
||
|
|
@export var turn_power : float = 1
|
||
|
|
|
||
|
|
# Called when the node enters the scene tree for the first time.
|
||
|
|
func _ready() -> void:
|
||
|
|
pass # Replace with function body.
|
||
|
|
|
||
|
|
|
||
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||
|
|
func _process(delta: float) -> void:
|
||
|
|
var turning : float = Input.get_axis("turn_left","turn_right") * turn_power
|
||
|
|
var thrust : float = Input.get_action_strength("thrust") * thrust_power
|
||
|
|
|
||
|
|
apply_torque(turning)
|
||
|
|
apply_force(Vector2(-thrust,-thrust) * transform.y )
|
||
|
|
|