From 975c2afca998d46b6420cbe86d9c92abf62e244e Mon Sep 17 00:00:00 2001 From: unfa Date: Sat, 1 Jan 2022 18:06:10 +0100 Subject: [PATCH] Fixed muzzle flash --- Game/Assets/Effects/MuzzleFlash.tscn | 21 +++++++++++++-------- Game/Assets/Weapons/Handgun/Flash.gd | 4 +++- Game/Assets/Weapons/Weapon.gd | 4 +--- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Game/Assets/Effects/MuzzleFlash.tscn b/Game/Assets/Effects/MuzzleFlash.tscn index 7e3bffa..598c112 100644 --- a/Game/Assets/Effects/MuzzleFlash.tscn +++ b/Game/Assets/Effects/MuzzleFlash.tscn @@ -46,11 +46,11 @@ colors = PackedColorArray(0, 0, 0, 1, 3, 2.4, 0.4, 1, 1.78272, 1.24586, 0.237743 gradient = SubResource( "Gradient_jrhpo" ) use_hdr = true -[sub_resource type="Curve" id="Curve_vfbna"] -_data = [Vector2(0, 0.154545), 0.0, 5.74743, 0, 0, Vector2(0.157761, 0.6), 1.49824, 1.49824, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] +[sub_resource type="Curve" id="Curve_dhha2"] +_data = [Vector2(0, 0.154545), 0.0, 5.74743, 0, 0, Vector2(0.173729, 0.872727), 1.49824, 1.49824, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] [sub_resource type="CurveTexture" id="CurveTexture_n25a7"] -curve = SubResource( "Curve_vfbna" ) +curve = SubResource( "Curve_dhha2" ) [sub_resource type="ParticlesMaterial" id="ParticlesMaterial_fglo4"] lifetime_randomness = 0.25 @@ -58,14 +58,13 @@ direction = Vector3(0, 0, -1) spread = 5.0 gravity = Vector3(0, 0, 0) initial_velocity_min = 5.0 -initial_velocity_max = 10.0 +initial_velocity_max = 25.0 angular_velocity_min = -5.0 angular_velocity_max = 5.0 -damping_min = 20.0 -damping_max = 26.0 +damping_min = 18.58 +damping_max = 18.67 angle_min = -180.0 angle_max = 180.0 -scale_min = 2.0 scale_max = 2.5 scale_curve = SubResource( "CurveTexture_n25a7" ) color_ramp = SubResource( "GradientTexture1D_lue3h" ) @@ -120,6 +119,12 @@ anims/Off = SubResource( "2" ) anims/RESET = SubResource( "3" ) [node name="GPUParticles3D" type="GPUParticles3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0) +emitting = false +amount = 32 +lifetime = 0.25 +one_shot = true +speed_scale = 2.0 explosiveness = 1.0 fixed_fps = 0 process_material = SubResource( "ParticlesMaterial_fglo4" ) @@ -147,7 +152,7 @@ color_ramp = SubResource( "9" ) anim_offset_max = 1.0 [node name="Timer" type="Timer" parent="."] -wait_time = 0.1 +wait_time = 0.5 one_shot = true autostart = true diff --git a/Game/Assets/Weapons/Handgun/Flash.gd b/Game/Assets/Weapons/Handgun/Flash.gd index b0655e6..5da6803 100644 --- a/Game/Assets/Weapons/Handgun/Flash.gd +++ b/Game/Assets/Weapons/Handgun/Flash.gd @@ -1,8 +1,10 @@ extends Node3D func _ready(): - $CPUParticles3D.emitting = true + print("Muzzle flash spawned") + $GPUParticles3D.emitting = true $AnimationPlayer.play("Flash") + func _on_Timer_timeout(): queue_free() diff --git a/Game/Assets/Weapons/Weapon.gd b/Game/Assets/Weapons/Weapon.gd index d3580e5..90736fd 100644 --- a/Game/Assets/Weapons/Weapon.gd +++ b/Game/Assets/Weapons/Weapon.gd @@ -42,13 +42,11 @@ var spread = spread_min $"SFX/Shoot C".play() var flash_effect = flash.instantiate() - flash_effect.global_transform = muzzle.global_transform get_parent().add_child(flash_effect) + flash_effect.global_transform = muzzle.global_transform animation_player.play("Shoot", 0, 2.5) - - var space_state = get_world_3d().direct_space_state var from = camera.get_global_transform().origin