Merge branch 'GunFunctionMove'
This commit is contained in:
@@ -212,6 +212,20 @@ tracks/6/keys = {
|
|||||||
"update": 0,
|
"update": 0,
|
||||||
"values": [0.0]
|
"values": [0.0]
|
||||||
}
|
}
|
||||||
|
tracks/7/type = "method"
|
||||||
|
tracks/7/imported = false
|
||||||
|
tracks/7/enabled = true
|
||||||
|
tracks/7/path = NodePath(".")
|
||||||
|
tracks/7/interp = 1
|
||||||
|
tracks/7/loop_wrap = true
|
||||||
|
tracks/7/keys = {
|
||||||
|
"times": PackedFloat32Array(0.28),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"values": [{
|
||||||
|
"args": [],
|
||||||
|
"method": &"spawn_mag"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_bsc1a"]
|
[sub_resource type="Animation" id="Animation_bsc1a"]
|
||||||
resource_name = "shoot"
|
resource_name = "shoot"
|
||||||
@@ -305,7 +319,7 @@ _data = {
|
|||||||
[node name="mac10" node_paths=PackedStringArray("flare_light", "anim_player", "barrel_raycast", "casing_ejector", "mag_ejector", "audio_fire", "audio_empty", "audio_reload") instance=ExtResource("1_nb4p5")]
|
[node name="mac10" node_paths=PackedStringArray("flare_light", "anim_player", "barrel_raycast", "casing_ejector", "mag_ejector", "audio_fire", "audio_empty", "audio_reload") instance=ExtResource("1_nb4p5")]
|
||||||
script = ExtResource("2_6i1l4")
|
script = ExtResource("2_6i1l4")
|
||||||
max_ammo = 30
|
max_ammo = 30
|
||||||
start_mags = 4
|
start_mags = 100
|
||||||
random_spread_amt = 1.5
|
random_spread_amt = 1.5
|
||||||
flare_light = NodePath("mac10/SpotLight3D")
|
flare_light = NodePath("mac10/SpotLight3D")
|
||||||
bullet = ExtResource("3_pyl20")
|
bullet = ExtResource("3_pyl20")
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ damping = 0.1
|
|||||||
wet = 0.1
|
wet = 0.1
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
bus/0/volume_db = -80.0
|
||||||
bus/0/effect/0/effect = SubResource("AudioEffectPitchShift_qiw0e")
|
bus/0/effect/0/effect = SubResource("AudioEffectPitchShift_qiw0e")
|
||||||
bus/0/effect/0/enabled = false
|
bus/0/effect/0/enabled = false
|
||||||
bus/1/name = &"SFX"
|
bus/1/name = &"SFX"
|
||||||
|
|||||||
637
scenes/tesDD33.tmp
Normal file
637
scenes/tesDD33.tmp
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,2 +0,0 @@
|
|||||||
[.ShellClassInfo]
|
|
||||||
IconResource=C:\Program Files\Google\Drive File Stream\93.0.1.0\GoogleDriveFS.exe,25
|
|
||||||
@@ -31,6 +31,7 @@ var random_spread_start
|
|||||||
@export var audio_reload : Node
|
@export var audio_reload : Node
|
||||||
|
|
||||||
@onready var player = $"../../../../"
|
@onready var player = $"../../../../"
|
||||||
|
var rng = RandomNumberGenerator.new()
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
@@ -55,3 +56,56 @@ func _on_gun_anims_animation_finished(anim_name):
|
|||||||
player.ammo += player.ammo_reserve
|
player.ammo += player.ammo_reserve
|
||||||
player.ammo_reserve -= player.ammo_reserve
|
player.ammo_reserve -= player.ammo_reserve
|
||||||
player.reloading = false
|
player.reloading = false
|
||||||
|
|
||||||
|
func shoot(player,delta):
|
||||||
|
if player.ammo > 0:
|
||||||
|
if !anim_player.is_playing():
|
||||||
|
player.ammo -= 1
|
||||||
|
#RECOIL --- fix later to happen over a period of time
|
||||||
|
player.camera.rotation.x = clamp(lerp(player.camera.rotation.x, player.camera.rotation.x + recoil_amount, delta * 10), deg_to_rad(-90), deg_to_rad(60))
|
||||||
|
#(ADD PLAYER KICK HERE. RELATIVE TO GUN POSITION)
|
||||||
|
audio_fire.pitch_scale = 1 + rng.randf_range(-.2,.2)
|
||||||
|
audio_fire.play()
|
||||||
|
anim_player.play("shoot")
|
||||||
|
|
||||||
|
# shoot real bullet from camera
|
||||||
|
|
||||||
|
var instance_bullet = bullet.instantiate()
|
||||||
|
instance_bullet.position = player.bullet_ray.global_position
|
||||||
|
#shoot bullet from real gun if gun is folded up
|
||||||
|
if player.gun_folded == false:
|
||||||
|
instance_bullet.transform.basis = player.bullet_ray.global_transform.basis
|
||||||
|
else:
|
||||||
|
instance_bullet.transform.basis = barrel_raycast.global_transform.basis
|
||||||
|
instance_bullet.bullet_speed = bullet_speed
|
||||||
|
instance_bullet.bullet_drop = bullet_drop
|
||||||
|
instance_bullet.random_spread_amt = random_spread_amt
|
||||||
|
instance_bullet.gun = self
|
||||||
|
get_tree().get_root().add_child(instance_bullet)
|
||||||
|
|
||||||
|
# Casing transform
|
||||||
|
var instance_casing = casing.instantiate()
|
||||||
|
instance_casing.position = casing_ejector.global_position
|
||||||
|
instance_casing.transform.basis = casing_ejector.global_transform.basis
|
||||||
|
get_tree().get_root().add_child(instance_casing)
|
||||||
|
|
||||||
|
elif !anim_player.is_playing():
|
||||||
|
anim_player.play("empty")
|
||||||
|
audio_empty.play()
|
||||||
|
|
||||||
|
func reload(player,delta):
|
||||||
|
if player.ammo < max_ammo and player.reloading == false and player.ammo_reserve > 0:
|
||||||
|
player.reloading = true
|
||||||
|
anim_player.play("reload")
|
||||||
|
audio_reload.play()
|
||||||
|
if anim_player.is_playing() and anim_player.current_animation == "reload":
|
||||||
|
if player.ammo == 0:
|
||||||
|
player.ammo = 0
|
||||||
|
else:
|
||||||
|
player.ammo = 1
|
||||||
|
|
||||||
|
func spawn_mag():
|
||||||
|
var instance_mag = mag.instantiate()
|
||||||
|
instance_mag.position = mag_ejector.global_position
|
||||||
|
instance_mag.transform.basis = mag_ejector.global_transform.basis
|
||||||
|
get_tree().get_root().add_child(instance_mag)
|
||||||
|
|||||||
@@ -152,58 +152,14 @@ func _physics_process(delta):
|
|||||||
|
|
||||||
# Reloading
|
# Reloading
|
||||||
if Input.is_action_just_pressed("reload"):
|
if Input.is_action_just_pressed("reload"):
|
||||||
if ammo < gun.max_ammo and reloading == false and ammo_reserve > 0:
|
gun.reload(self,delta)
|
||||||
reloading = true
|
|
||||||
gun.anim_player.play("reload")
|
|
||||||
gun.audio_reload.play()
|
|
||||||
instance_mag = gun.mag.instantiate()
|
|
||||||
await get_tree().create_timer(.28).timeout
|
|
||||||
instance_mag.position = gun.mag_ejector.global_position
|
|
||||||
instance_mag.transform.basis = gun.mag_ejector.global_transform.basis
|
|
||||||
get_parent().add_child(instance_mag)
|
|
||||||
if gun.anim_player.is_playing() and gun.anim_player.current_animation == "reload":
|
|
||||||
if ammo == 0:
|
|
||||||
ammo = 0
|
|
||||||
else:
|
|
||||||
ammo = 1
|
|
||||||
if Input.is_action_pressed("inspect") and !gun.anim_player.is_playing():
|
if Input.is_action_pressed("inspect") and !gun.anim_player.is_playing():
|
||||||
gun.anim_player.play("inspect")
|
gun.anim_player.play("inspect")
|
||||||
|
|
||||||
# Shooting
|
# Shooting
|
||||||
if Input.is_action_pressed("shoot"):
|
if Input.is_action_pressed("shoot"):
|
||||||
if ammo > 0:
|
gun.shoot(self,delta)
|
||||||
if !gun.anim_player.is_playing():
|
|
||||||
ammo -= 1
|
|
||||||
#RECOIL fix later to happen over a period of time
|
|
||||||
camera.rotation.x = clamp(lerp(camera.rotation.x, camera.rotation.x + gun.recoil_amount, delta * 10), deg_to_rad(-90), deg_to_rad(60))
|
|
||||||
#(ADD PLAYER KICK HERE. RELATIVE TO GUN POSITION)
|
|
||||||
gun.audio_fire.pitch_scale = 1 + rng.randf_range(-.2,.2)
|
|
||||||
gun.audio_fire.play()
|
|
||||||
gun.anim_player.play("shoot")
|
|
||||||
|
|
||||||
# shoot real bullet from camera
|
|
||||||
|
|
||||||
instance_bullet = gun.bullet.instantiate()
|
|
||||||
if gun_folded == false:
|
|
||||||
instance_bullet.position = bullet_ray.global_position
|
|
||||||
else:
|
|
||||||
instance_bullet.position = gun.barrel_raycast.global_position
|
|
||||||
instance_bullet.transform.basis = bullet_ray.global_transform.basis
|
|
||||||
instance_bullet.bullet_speed = gun.bullet_speed
|
|
||||||
instance_bullet.bullet_drop = gun.bullet_drop
|
|
||||||
instance_bullet.random_spread_amt = gun.random_spread_amt
|
|
||||||
instance_bullet.gun = gun
|
|
||||||
print("bullet coords: " + str(instance_bullet.position))
|
|
||||||
get_parent().add_child(instance_bullet)
|
|
||||||
# Casing transform
|
|
||||||
instance_casing = gun.casing.instantiate()
|
|
||||||
instance_casing.position = gun.casing_ejector.global_position
|
|
||||||
instance_casing.transform.basis = gun.casing_ejector.global_transform.basis
|
|
||||||
|
|
||||||
get_parent().add_child(instance_casing)
|
|
||||||
elif !gun.anim_player.is_playing():
|
|
||||||
gun.anim_player.play("empty")
|
|
||||||
gun.audio_empty.play()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -271,8 +227,8 @@ func weapon_tilt(input_x, delta):
|
|||||||
|
|
||||||
func weapon_sway(delta):
|
func weapon_sway(delta):
|
||||||
mouse_input = lerp(mouse_input, Vector2.ZERO, 10 * delta)
|
mouse_input = lerp(mouse_input, Vector2.ZERO, 10 * delta)
|
||||||
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, mouse_input.y * weapon_rotation_amount, 10 * delta)
|
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, mouse_input.y * weapon_rotation_amount, 1 * delta)
|
||||||
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, mouse_input.x * weapon_rotation_amount, 10 * delta)
|
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, mouse_input.x * weapon_rotation_amount, 1 * delta)
|
||||||
|
|
||||||
#crosshair.position.x = lerp(crosshair.position.x, mouse_input.x * 100, 2 * delta)
|
#crosshair.position.x = lerp(crosshair.position.x, mouse_input.x * 100, 2 * delta)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user