tweaked bullet and pick up method
This commit is contained in:
@@ -26,7 +26,6 @@ var rng = RandomNumberGenerator.new()
|
||||
|
||||
@export_group("Game Settings")
|
||||
@export var AUDIO = true
|
||||
@export var dead_player : Resource
|
||||
@export_group("Player Movement")
|
||||
|
||||
@export var DASH_STAM_REQ = 10
|
||||
@@ -50,7 +49,7 @@ var start_sensitivity
|
||||
#@export
|
||||
|
||||
var gun : Node
|
||||
|
||||
@onready var dead_player : Resource = load("res://assets/dead_cam.tscn")
|
||||
@onready var pause_menu: Control = $Head/Recoil/Camera3D/PauseMenu
|
||||
@onready var gun_ray = $Head/Recoil/Camera3D/GunRay
|
||||
@onready var level_control = get_tree().current_scene
|
||||
@@ -80,6 +79,7 @@ var held_item_linear_damp_cache
|
||||
var held_item_angular_damp_cache
|
||||
var held_item_gravity_cache
|
||||
var held_item_mass_cache
|
||||
var held_item_rotation = Vector3(0,0,0)
|
||||
|
||||
# Slow Down Variables
|
||||
var remaining_stamina = MAX_STAMINA
|
||||
@@ -298,15 +298,22 @@ func _physics_process(delta):
|
||||
|
||||
#Weapon Swap Up
|
||||
if Input.is_action_just_pressed("scroll_up") and !gun.anim_player.is_playing():
|
||||
if level_control.held_guns.size() > 1:
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(level_control.current_gun_index + 1)
|
||||
if held_item == null:
|
||||
if level_control.held_guns.size() > 1:
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(level_control.current_gun_index + 1)
|
||||
else:
|
||||
held_item_rotation.y += deg_to_rad(45)
|
||||
|
||||
#Weapon Swap Down
|
||||
if Input.is_action_just_pressed("scroll_down") and !gun.anim_player.is_playing():
|
||||
if level_control.held_guns.size() > 1:
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(level_control.current_gun_index - 1)
|
||||
|
||||
if held_item == null:
|
||||
if level_control.held_guns.size() > 1:
|
||||
gun.anim_player.play("swap_out")
|
||||
level_control.gun_spawn(level_control.current_gun_index - 1)
|
||||
else:
|
||||
held_item_rotation.y -= deg_to_rad(45)
|
||||
|
||||
# Weapon Swap Number 1
|
||||
if Input.is_action_just_pressed("numb_1") and !gun.anim_player.is_playing():
|
||||
weapon_select(0)
|
||||
@@ -328,7 +335,8 @@ func _physics_process(delta):
|
||||
if held_item != null:
|
||||
var held_force_dir = moveable_holder.global_position - held_item.global_position
|
||||
held_item.set_constant_force(held_force_dir * 30)
|
||||
#held_item.rotation = lerp(held_item.rotation, rotation, delta)
|
||||
held_item.rotation = lerp(held_item.rotation, held_item_rotation, delta)
|
||||
print("HELD ITEM ROTATION " + str(rad_to_deg(held_item_rotation.y)))
|
||||
|
||||
#break when moved too far away
|
||||
var distance_from_player = abs(self.global_position - held_item.global_position)
|
||||
@@ -353,6 +361,8 @@ func _physics_process(delta):
|
||||
if interact_ray.get_collider().is_in_group("scene_rigidbody"):
|
||||
kick_audio.play()
|
||||
interact_ray.get_collider().linear_velocity += transform.basis * Vector3(0,0,-KICK_AMOUNT)
|
||||
if held_item != null:
|
||||
release_moveable()
|
||||
|
||||
|
||||
|
||||
@@ -435,7 +445,7 @@ func toggle_hud(hud_on):
|
||||
func grab_moveable(body):
|
||||
moveable_holder.global_position = body.global_position
|
||||
held_item = body
|
||||
|
||||
held_item_rotation = body.rotation
|
||||
#cache rigidbody settings
|
||||
held_item_linear_damp_cache = body.linear_damp
|
||||
held_item_angular_damp_cache = body.angular_damp
|
||||
@@ -449,6 +459,7 @@ func grab_moveable(body):
|
||||
held_item.gravity_scale = 0
|
||||
|
||||
func release_moveable():
|
||||
held_item_rotation = Vector3(0,0,0)
|
||||
held_item.gravity_scale = held_item_gravity_cache
|
||||
held_item.linear_damp = held_item_linear_damp_cache
|
||||
held_item.angular_damp = held_item_angular_damp_cache
|
||||
|
||||
Reference in New Issue
Block a user