Effect to appear when right mouse click

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

I want a white water ripple effect like circle to appear where I right clicked. I can draw the effect myself.
How do I make it appear? Do I make it a scene and instance it where I clicked. And I could just put a queue_free at the end of it’s animation to delete it.
But is there another perhaps better way using the UI system?

Have you looked into using a CanvasLayer for this effect? Have the CanvasLayer play the ripple effect at the place the player clicks, and hide the CanvasLayer when it finishes playing.

Ertain | 2022-06-10 19:00

Thanks for the suggestion. I will check out some canvas layer tutorials.

Skydome | 2022-06-11 06:51

:bust_in_silhouette: Reply From: DaddyMonster

If I understand you right, you want to spawn an object when you click. Then this:

var splash_scene = preload("drag_your_tscn_scene_from_the bottom_left_window_to_here")

func _input(event):
	if event is InputEventMouseButton:
		var splash = splash_scene.instance()
		splash.position = event.position

To delete it when you’re done, add a “Call Method Track” to your AnimationPlayer and call a queue_free method on the last frame.

So you know, this can also be achieved with a shader but that’s a little more advanced.

Thank you for your reply. I did know about this method since I use this for Ki Blast spawning. But I thought maybe one of the UI nodes has a better way.
Thanks again.

Skydome | 2022-06-11 06:42

That’s the way I’d do it. Otherwise, you could maybe do it with a particle (meh, more hassle than it’s worth) or you could use a canvas layer I suppose (I don’t know why you would). Anything else is just making life complicated for no reason imho. I don’t know anything in the UI which handles this. Apart from the shader which gives advantages in certain situation, is generally performant but much more of a pain to implement.

Simple is always good. :slight_smile:

DaddyMonster | 2022-06-11 13:31

Yea I have chosen this way. I just thought there would be a different maybe better way of handling mouse related things like custom curser and curser effects and click effects. But in this case it’s better to do it the way you suggested.

Skydome | 2022-06-11 15:56