Particle Attraction

Hi all. I’m new to Unity.

I want to emit particles from a circle’s perimeter and attract the particles to the center of the circle.

I’ve been able to emit the particles on the circle’s perimiter

Is it possible for me to make a script which each particle inherits upon creation and will move the particle towards the circle’s center?

If this action can be accomplished via scripting, how do I attach the script to the particles? Would the script be placed on the emitter ?

tangentVelocity.z is the variable for the particleEmitter that affects the direction towards or away from center that the particles go.

So, if you set tangent velocity z to -1, you’ll go towards the center at 1 unit per second. If it’s 1, you’ll go away from center at 1 unit per second.

This did not work for me.
I made a polygon circle in Maya. Imported in to Unity.
The particles are created at the vertices of my model as expected.

I enter -1 in the gui’s entry box for tangentVelocity.z

The particles remain motionless at the perimeter of the circle.

Not sure what the Z axis is in Unity, is it front to back?
One more thing might that be affecting the movement is scale, if your scale is very large a -1 might seem like it’s not moving.

Yes in my case. z is front to back.

I think to achieve the action I wish, I’ll have to write a per particle/per frame script which applies a velocity to the particle which heads it to destination.

Actually, Gargerath has the right idea. I’ve done implosions that way; it works fine. Also, using the normal velocity for a mesh emitter makes particles go in whatever direction the mesh normals are pointing.

–Eric

Hello, this can be quite easily done by making the Shape of your emitter a sphere (for a 3d circle) or cone (for a 2d circle). Make sure Emit from Shell is checked and make the speed negative. You will have to adjust the lifetime, radius and speed of the emitter accordingly (so that the particle dies when it reaches the centre as oppose to passing through it) but this will allow you to draw particles inwards.

It is not technically particle ‘attraction’, since there is no object the particles are actually attracted to using the above trick, however it may solve your problem if all you need is to emit particles towards a central point. Tweaking your colour over time (or making it a random between two gradients) can also make it look like the particles are being emitted from different points within the circle (not just the shell) and still make sure they die upon reaching the centre since their lifetime is the same.

Good luck!