Seems more reliable than the original method but not perfect. Added number based weapon switching

This commit is contained in:
derek
2024-10-29 17:00:46 -05:00
parent 00aa8db85d
commit 7c32586348
5 changed files with 62 additions and 5 deletions

View File

@@ -1,8 +1,9 @@
[gd_scene load_steps=67 format=4 uid="uid://6agmt1hqlhww"]
[gd_scene load_steps=68 format=4 uid="uid://6agmt1hqlhww"]
[ext_resource type="Script" path="res://scripts/LevelManager.gd" id="1_sbpvn"]
[ext_resource type="PackedScene" uid="uid://brl0bsqjl5dg3" path="res://assets/mac_10.tscn" id="2_fn4vb"]
[ext_resource type="Texture2D" uid="uid://ckjcv72jcojjh" path="res://assets/materials/91_laurel hedge PBR texture-seamless_hr/91_laurel hedge_DIFF (Custom).jpg" id="3_3ov8a"]
[ext_resource type="PackedScene" uid="uid://b5eclfg0cmmal" path="res://assets/revolver_1.tscn" id="3_7475s"]
[ext_resource type="LightmapGIData" uid="uid://bwpvltmeo4cfl" path="res://assets/LevelBlockouts/blockout_2.lmbake" id="3_d2pxn"]
[ext_resource type="Texture2D" uid="uid://d210plbmb7a2o" path="res://assets/materials/91_laurel hedge PBR texture-seamless_hr/91_laurel hedge_NORM (Custom).jpg" id="4_5u2rd"]
[ext_resource type="PackedScene" uid="uid://20csd6dmwj4y" path="res://assets/jump_platform.tscn" id="4_j47q8"]
@@ -641,6 +642,7 @@ player = NodePath("Player")
money = 50
start_health = 5
gun_1 = ExtResource("2_fn4vb")
gun_2 = ExtResource("3_7475s")
health_drop_enabled = false
[node name="Player" parent="." instance=ExtResource("9_3usor")]

View File

@@ -134,6 +134,31 @@ kick={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":113,"location":0,"echo":false,"script":null)
]
}
numb_1={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":49,"key_label":0,"unicode":49,"location":0,"echo":false,"script":null)
]
}
numb_2={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":50,"key_label":0,"unicode":50,"location":0,"echo":false,"script":null)
]
}
numb_3={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":51,"key_label":0,"unicode":51,"location":0,"echo":false,"script":null)
]
}
numb_4={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":52,"key_label":0,"unicode":52,"location":0,"echo":false,"script":null)
]
}
numb_5={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":53,"key_label":0,"unicode":53,"location":0,"echo":false,"script":null)
]
}
[layer_names]

View File

@@ -21,7 +21,7 @@ var player_velocity
func _ready():
visible = false
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed) + player_velocity
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed)
# Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -31,7 +31,7 @@ func _physics_process(delta):
distance_from_player = abs(self.global_position - player_position)
if distance_from_player.x > 2 or distance_from_player.y > 2 or distance_from_player.z > 2:
if distance_from_player.length() > 1.5:
visible = true

View File

@@ -211,7 +211,7 @@ func _physics_process(delta):
#Land Sound
if velocity.y < .1 and self.is_on_floor() and moving_fast == true:
var land_volume = clamp( moving_fast_top_speed - 20 ,-10,0)
var recoil_amount = Vector3(-.1,0,0)
var recoil_amount = Vector3(-.3,0,0)
land_sound.volume_db = land_volume
land_sound.play()
recoil.add_recoil(recoil_amount,10,2)
@@ -284,6 +284,36 @@ func _physics_process(delta):
gun.anim_player.play("swap_out")
level_control.gun_spawn(level_control.current_gun_index - 1)
# Weapon Swap Number 1
if Input.is_action_just_pressed("numb_1") and !gun.anim_player.is_playing():
var gun_id = 0
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
gun.anim_player.play("swap_out")
level_control.gun_spawn(gun_id)
if Input.is_action_just_pressed("numb_2") and !gun.anim_player.is_playing():
var gun_id = 1
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
gun.anim_player.play("swap_out")
level_control.gun_spawn(gun_id)
if Input.is_action_just_pressed("numb_3") and !gun.anim_player.is_playing():
var gun_id = 2
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
gun.anim_player.play("swap_out")
level_control.gun_spawn(gun_id)
if Input.is_action_just_pressed("numb_4") and !gun.anim_player.is_playing():
var gun_id = 3
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
gun.anim_player.play("swap_out")
level_control.gun_spawn(gun_id)
if Input.is_action_just_pressed("numb_5") and !gun.anim_player.is_playing():
var gun_id = 4
if level_control.held_guns[gun_id] != null and level_control.current_gun_index != gun_id:
gun.anim_player.play("swap_out")
level_control.gun_spawn(gun_id)
#interact button
if Input.is_action_just_pressed("interact"):

View File

@@ -14,7 +14,7 @@ var player_position
# Called when the node enters the scene tree for the first time.
func _ready():
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed) + player_velocity
linear_velocity += transform.basis * Vector3(0, 0, -bullet_speed)
blast_radius = radius_shape.shape.radius
# Called every frame. 'delta' is the elapsed time since the previous frame.