How can I make particles when generated by clicking a button?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Juliang2000

Hi, I’m new to Godot and I want to click on a button to generate particles and I don’t know how to do it or if it’s not possible how I can do to click on a specific area of my scene and when doing so the particles come out

I suggest you change your question or edit this one to better fit what you want. I can see as you asking two things:

  1. Generate the particles itself. where you can use the Particles or Particles2D node and add it to the scene and remove as you want.
  2. Detect where the mouse is in the scene so you can set your particles scene, from above, to the correct place. Simple on 2d, i think you can get it from the mouse click event, on 3d you have to also discover where the mouse was pointing in the envionment.

tastyshrimp | 2019-12-12 22:29

:bust_in_silhouette: Reply From: Xtremezero
extends Particles

func _ready():
	# one_shot means you particle system will not repeat after it finishes
	one_shot = true

func _input(event):
	if event is InputEventMouseButton:
		
		#event.pressed is True when pressed / False when released
		if event.pressed == false and event.button_index== BUTTON_LEFT:
			emitting = true   # This will start the particle system