added hold check to interact button

This commit is contained in:
derek
2025-02-06 16:48:46 -06:00
parent c10e3800f0
commit c04423406b
8 changed files with 22 additions and 19 deletions

View File

@@ -20,6 +20,7 @@ const HEAD_TILT_AMT = .06
const BOB_FREQ = 1.7
const BOB_AMP = 0.1
const ADS_POS = Vector3(0,-.05,-.3)
const HELD_BUTTON_AMT = 1.0 #in seconds
#JOYSTICK SETTINGS
const JOYSTICK_SENSITIVITY = .06
@@ -103,6 +104,7 @@ var flashlight_on : bool = false
##CACHED VARS
var weapon_start_pos
var held_key_check = 0.0
# Slow Down Variables
var remaining_stamina : float = MAX_STAMINA
@@ -437,16 +439,23 @@ func _physics_process(delta):
controlled_elsewhere = false
#interact button
if Input.is_action_just_pressed("interact"):
if Input.is_action_pressed("interact"):
held_key_check += delta
## IF HELD
if held_key_check >= HELD_BUTTON_AMT:
if held_item != null:
release_moveable()
elif interact_ray.is_colliding():
var body = interact_ray.get_collider()
if interact_ray.get_collider().is_in_group("interact"):
body.get_parent().interact()
if interact_ray.get_collider().get_class() == "RigidBody3D":
grab_moveable(body)
held_key_check = 0.0
elif Input.is_action_just_released("interact"):
if interact_ray.is_colliding():
var body = interact_ray.get_collider()
if interact_ray.get_collider().has_method("interact"):
body.interact()
held_key_check = 0.0
#kick
if Input.is_action_just_pressed("kick"):