I’m trying to have it where when a gun fires it emits some gun smoke using GPUparticles2D, however the GPUparticles2D node has to wait for the old some to reach the end of their life time before emitting more particles. Also the gun doesn’t emit more smoke even when held down and auto-fires.
Some messy code:
If Input.is_action_pressed (“Primary Shoot”) and can_fire:
var bullet_instance = bullet. instantiate()
bullet_instance.rotation = rotation
bullet_instance-global_position =$Position2D.global_position
If flip_v == false:
position.x = lerp(position.x, get_parent().position.x-3, 0.5)
Else:
position.x = lerp(position.x, get_parent().position.x+3, 0.5)
$GPUParticles2D.emitting = true
get_parent().add_child(bullet_instance)
can_fire = false
await get_tree.create_timer(PlayerAutoload.Fire_rate).timeout
can_fire = true
I am not sure this it true. Just call stop on it and set it emitting again.
Here I think you need to emit when a bullet is fired, and if the key is still pressed another bullet is fired, so you would stop the particles, then start emitting them again. Any existing smoke particles will continue on their life cycle.
If you have your settings set to explosive with randomness in their upward direction and a fair lifetime, say, rising up, on multiple shots you could build up quite a bit of smoke depending on your fire rate.
Change:
$GPUParticles2D.emitting = true
To
$GPUParticles2D.emitting = false #stops it if it is still emitting first
$GPUParticles2D.emitting = true # restarts it again
There are tons of settings but I would also set it the particles to one shot for the smoke.