XPilotGodot/World/PlayerInput.gd

24 lines
647 B
GDScript

extends MultiplayerSynchronizer
@export var rotate := 0.0
@export var thrust := false
@export var shoot := false
const ROTATION = 0.05
# Called when the node enters the scene tree for the first time.
func _ready():
# Only process for the local player
set_process(get_multiplayer_authority() == multiplayer.get_unique_id())
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
rotate = 0.0
if Input.is_action_pressed("left"):
rotate -= ROTATION
if Input.is_action_pressed("right"):
rotate += ROTATION
thrust = Input.is_action_pressed("thrust")
shoot = Input.is_action_pressed("shoot")