more various tweaks to held items and chests in order to make carrying chests fun

This commit is contained in:
derek
2025-03-04 17:02:52 -06:00
parent e84aea9ef7
commit 5d989470a6
20 changed files with 111 additions and 106 deletions

View File

@@ -86,6 +86,7 @@ var current_weapon_index
var recoiling = false
var dead = false
var hud_visible : bool = true
var held_item : Node
var held_item_linear_damp_cache
var held_item_angular_damp_cache
@@ -93,7 +94,8 @@ var held_item_gravity_cache
var held_item_mass_cache
var held_item_collision_cache
var hold_offset
var held_item_rotation = Vector3(0,0,0)
var held_item_rotation : float = 0
var gamespeed_controlled = false
var crouched = false
var flashlight_on : bool = false
@@ -137,7 +139,6 @@ var controlled_elsewhere = false
@onready var weapon_pickup_audio: AudioStreamPlayer = $Audio/WeaponPickup
@onready var motion_lines: ColorRect = $Head/Recoil/Camera3D/MotionLines
@onready var moveable_holder: Node3D = $Head/Recoil/Camera3D/MoveableHolder
@onready var moveable_rotation: Node3D = $Head/Recoil/Camera3D/MoveableHolder/MoveableRotation
@onready var stand_check: RayCast3D = $StandCheck
@onready var r_hand_test: MeshInstance3D = $Head/Recoil/Camera3D/WeaponHolder/RHandTest
@onready var enemy_killed_audio: AudioStreamPlayer = $Audio/EnemyKilled
@@ -405,13 +406,14 @@ func _physics_process(delta):
#Weapon Swap Up
if Input.is_action_just_pressed("scroll_up"):
if held_item != null:
held_item_rotation += deg_to_rad(45)
print("HELD ITEM ROTATION : ",held_item_rotation)
if gun != null:
if !gun.anim_player.is_playing():
if held_item == null:
if GameGlobals.held_guns.size() > 1:
weapon_select(GameGlobals.current_gun_index + 1)
else:
moveable_holder.rotation.y += deg_to_rad(45)
else:
if gun_is_holstered:
holster_gun(false)
@@ -424,7 +426,7 @@ func _physics_process(delta):
if GameGlobals.held_guns.size() > 1:
weapon_select(GameGlobals.current_gun_index - 1)
else:
moveable_holder.rotation.y -= deg_to_rad(45)
held_item_rotation -= deg_to_rad(45)
else:
if gun_is_holstered:
holster_gun(false)
@@ -461,6 +463,12 @@ func _physics_process(delta):
held_key_check += delta
## IF HELD
if held_key_check >= HELD_BUTTON_AMT:
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
elif Input.is_action_just_released("interact"):
if held_item != null:
release_moveable()
elif interact_ray.is_colliding():
@@ -468,13 +476,6 @@ func _physics_process(delta):
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"):
if !animation_player.is_playing():
@@ -626,9 +627,8 @@ func hold_item(_delta):
if held_item != null:
interact_ray.look_at(held_item.global_position, Vector3.UP)
var held_dir = (moveable_holder.global_position - held_item.global_position) #+ hold_offset
held_item.linear_velocity = held_dir * 15
held_item.look_at(moveable_rotation.global_position, Vector3.UP)
held_item.linear_velocity = held_dir * 50
held_item.rotation = Vector3(0,held_item_rotation,0) + Vector3(0,camera.global_rotation.y,0)
#break when moved too far away
var distance_from_player = abs(self.global_position - held_item.global_position)
if distance_from_player.length() > 5:
@@ -647,7 +647,6 @@ func release_moveable():
held_item.set_collision_layer_value(1,held_item_collision_cache)
held_item = null
hold_offset = null
moveable_holder.rotation = Vector3(0,0,0)
## GUNS AND AMMO
func holster_gun(holster):