Fixed muzzle flash

This commit is contained in:
unfa 2022-01-01 18:06:10 +01:00
parent 021168a507
commit 975c2afca9
3 changed files with 17 additions and 12 deletions

View file

@ -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

View file

@ -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()

View file

@ -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