Making particles move to a single point

#1

Hello! I’m trying to use particles as an indication that a certain action affected a certain resource. Do to this I want the action that can happen in any “playable” area (essentially a sub-area of the screen minus the GUI) to emit particles that move towards the resource icon (specific screen x/y coordinates on the GUI).

I’ve looked over the manuals but can’t quite see how to make it behave like I want it to. Does anyone have advice or examples?

0 Likes

#2

Could you illustrate what you want to happen? Just a simple movement or something continuous? There are various ways to get something similar to what you describe.

You could also code a custom particle system. Even inside of GUI.

0 Likes

#3

Essentially I want there to be a burst emission of particles (achieved with circle emitter) and for those particles to then move the a specific point (x,y) and disappear.

Do you know of any public examples of custom particle systems? I’m assuming it’s something smarter/more efficient than just creating N sprites and updating them each frame individually.

1 Like

#4

Nah, not really. I don’t see how else you’d make a custom particle effects system. Just take care not to do too many allocations if possible.

1 Like

#5

@Alesis there is a Vortex modifier that is able to lure your particles inside,l and you can adjust particle lifetime, but I guess you want a dynamic effect of “collecting coins to the bag/character” or something like this? If so, you will probably need to make something custom, a controller game object with a factory of particles and a script to control them all - use two properties - point of creation of particles and point of destination and then use some go.animate on your particles, generate vectors with a beginning in the starting point to get some points where particles will travel when burst out and perhaps some bezier curve or other way to achieve a smooth path transition between bursting out andoving to the destination? Or simplest solution if it is enough - you can burst particles with a simple linear go.animate, slowing them down in the end of the path and then simply attract them to the destination point with second go.animate :wink:

2 Likes

#6

What you described is essentially what I want to achieve - seems I’ll have to write a custom particle controller like you’ve described. I was just wondering if the particle fx objects do something smarter than just have N game objects - I do wonder how performant iterating over lists of particle sprites will be if I just code it naively.

1 Like

#7

I would spawn few particles (i.e. game object) each frame, for each particle launch two animations: one for x and one for y (in order to have curve trajectories) and call delete at the end of the animations. I would guess Defold is well capable of doing this. On the other hand I would avoid having an update function for each particles.

Ciao!

2 Likes

#8

Iterating over a list of particles and updating them should be well within the capabilities of the engine. You could also optimise it if needed and along with the id of each particle also store a v3 to hold the position so that you don’t have to do a go.get_position(id) every frame.

2 Likes

#9

Seems like a custom particle emitter object is the way to go then! Thanks!

1 Like

#10

By the way, since it’s > 2 years later, is this still the recommended way of drawing sprites over the GUI: Draw Sprite After GUI Is Drawn In Custom Render? (SOLVED)

Relevant because I’d need my particles to be on top of everything.

1 Like

#11

Yes, a new material with a different tag which you draw last in your render script

2 Likes