Prevent tool from auto-firing after object is thrown

This commit is contained in:
Rob Kelly 2025-09-07 13:31:23 -06:00
parent 667aa38cda
commit 24d34235ee
2 changed files with 10 additions and 1 deletions

View File

@ -28,6 +28,9 @@ const THROW_TUTORIAL_DELAY := 6.0
## Temporary collision mask.
@export_flags_3d_physics var hold_collision_physics := 0b01000001
## This is set when an object is thrown and released when the mouse button is released
var just_threw_object := false
## The object currently being held.
var _held_object: RigidBody3D
@ -108,6 +111,7 @@ func _process_hold_controls() -> void:
drop()
elif Input.is_action_just_pressed("fire"):
throw()
just_threw_object = true
func _physics_process(delta: float) -> void:
@ -115,6 +119,10 @@ func _physics_process(delta: float) -> void:
if holding_object():
_process_hold_controls()
# Release held object lockout as soon as possible
if not Input.is_action_pressed("fire"):
just_threw_object = false
# Held object logic
if not holding_object():
return

View File

@ -216,7 +216,8 @@ func _physics_process(delta: float) -> void:
firing = false
if tool:
# Tool use
if Input.is_action_pressed("fire"):
# Lockout fire input after throwing an object until input is released.
if Input.is_action_pressed("fire") and not hold_component.just_threw_object:
tool.fire()
firing = true
else: