tweaked bullet and pick up method
This commit is contained in:
@@ -34,38 +34,35 @@ func _physics_process(delta):
|
||||
|
||||
if distance_from_player.length() > 1.5:
|
||||
visible = true
|
||||
|
||||
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
|
||||
if !body.is_in_group("player") and bullet_active:
|
||||
print("BODY HIT - " + str(body))
|
||||
|
||||
#Break Breakable Objects
|
||||
if body.is_in_group("breakable"):
|
||||
body.breaking(linear_velocity)
|
||||
|
||||
if body.is_in_group("switch"):
|
||||
body.hit()
|
||||
|
||||
if ray.is_colliding() and !ray.get_collider().is_in_group("player"):
|
||||
#Bullet Hole Effect
|
||||
ray.get_collider().add_child(instance_bullethole)
|
||||
instance_bullethole.global_transform.origin = ray.get_collision_point()
|
||||
if (abs(ray.get_collision_normal().y) > 0.99):
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal(), Vector3(0,0,1))
|
||||
else:
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal())
|
||||
|
||||
#Hit Enemies
|
||||
if ray.get_collider().is_in_group("enemy_target"):
|
||||
hit_indicator.play()
|
||||
enemy_particles.emitting = true
|
||||
SignalBus.emit_signal("enemy_hit")
|
||||
ray.get_collider().hit(bullet_damage)
|
||||
if ray.is_colliding() and !ray.get_collider().is_in_group("player"):
|
||||
|
||||
mesh.visible = false
|
||||
bullet_active = false
|
||||
particles.emitting = true
|
||||
await get_tree().create_timer(1).timeout
|
||||
ray.enabled = false
|
||||
|
||||
#bullethole effect
|
||||
ray.get_collider().add_child(instance_bullethole)
|
||||
instance_bullethole.global_transform.origin = ray.get_collision_point()
|
||||
if (abs(ray.get_collision_normal().y) > 0.99):
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal(), Vector3(0,0,1))
|
||||
else:
|
||||
instance_bullethole.look_at(ray.get_collision_point() + ray.get_collision_normal())
|
||||
|
||||
if ray.get_collider().is_in_group("switch"):
|
||||
ray.get_collider().hit()
|
||||
|
||||
#move rigidbodies
|
||||
if ray.get_collider().is_in_group("scene_rigidbody"):
|
||||
ray.get_collider().linear_velocity += transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||
|
||||
if ray.get_collider().is_in_group("breakable"):
|
||||
var current_velocity = transform.basis * Vector3(0,0,-1 * bullet_force_mod)
|
||||
ray.get_collider().breaking(current_velocity)
|
||||
|
||||
|
||||
if ray.get_collider().is_in_group("enemy_target"):
|
||||
hit_indicator.play()
|
||||
enemy_particles.emitting = true
|
||||
ray.get_collider().hit(bullet_damage)
|
||||
await get_tree().create_timer(1.0).timeout
|
||||
queue_free()
|
||||
|
||||
@@ -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