From 8a41653dbbdebba4d6b15ab28b19b9892f5cbd71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Fri, 21 Jan 2022 16:55:27 +0100 Subject: [PATCH] Prevent multiple gear switches on single action with manual transmission --- player/vehicle_controller.gd | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/player/vehicle_controller.gd b/player/vehicle_controller.gd index bb0538f..9198002 100644 --- a/player/vehicle_controller.gd +++ b/player/vehicle_controller.gd @@ -6,8 +6,7 @@ export(NodePath) var vehicle_path = null onready var _vehicle: BuggedVehicle = get_node(vehicle_path) -func _input(_event: InputEvent) -> void: - # Using _input just to make sure events are captured right away +func _physics_process(_delta: float) -> void: _vehicle.inputs.throttle = Input.get_action_strength("throttle") _vehicle.inputs.clutch = Input.get_action_strength("clutch") _vehicle.inputs.brake = Input.get_action_strength("brake") @@ -22,7 +21,7 @@ func _input(_event: InputEvent) -> void: _vehicle.inputs.steering = steering_input if Input.is_action_just_pressed("gear_up"): _vehicle.inputs.gear_request = BuggedVehicle.GearRequest.UP - elif Input.is_action_pressed("gear_down"): + elif Input.is_action_just_pressed("gear_down"): _vehicle.inputs.gear_request = BuggedVehicle.GearRequest.DOWN else: _vehicle.inputs.gear_request = BuggedVehicle.GearRequest.NONE