Particles: how to dynamically grow particles on top of mesh

I would like to grow particles only on the top of meshes, the particles need to stick even when the object moves… how would I do this ?

I tried it with a particle system which drops particles with a World Collider attached to the system but the particles slide past the objects instead of sticking to it.

The particle animator has a flag called animate in world space. Check that off.

No I cannot use mesh emitter because the particles need to appear accross multiple meshes, so I drop them - problem is they don’t stick on the surface, they slide…

By the way, I tried to access particles individually to lock their position, after turning on send message in world collider, but I do not know how to access per particle collision so I do not know which ones collider… any hint ?

I didn’t say a word about mesh particle emitter. Emit particles as you like using the emit function. The flag you want to check off is ‘simulate in world space’ in the particle emitter. That makes all particles move along the transform.

The issue of having the particles stop and stick to the surface remains, any idea on this ?

Have you actually tried the flag?

The only thing you need to do is make sure the particles have no velocity when you emit them, then you can move the transform around as you like and the particles will stick to it.

I think he wants to have the particles emitted from one object but then stick to one or more other objects the particles collide with. But from my experience with it, the “simulate in world space” flag turned off will cause the particles will move with the emitter but not any objects they collide with.

Let me explain differently.

Imagine you are sitting on a bench and the snow starts falling.
The snow flocks are particles.
As they fall on your head, not under your jaw, they stick and remain there, same for the bench.
So after an hour you have snow on your head, shoulder, lap, upward facing of your hands and arms, not under your legs, not under your feet… and on the bench.

Now you stand up and the snow falls from you.

This is what I want to achieve.

One way to figure out which particle hit an object is to see which particle is the closest to the collider. For example:

function OnParticleCollision (collision) {
var closest : Vector3 = transform.position;
		for (particle in particleEmitter.particles) {
			if (Vector3.Distance(particle.position, collision.transform.position) < Vector3.Distance(closest, collision.transform.position))
			closest = particle.position;
		}
}

I think you would want to use a for (i==0; i<particles.length; i++) loop though. Also, one area that this fails is for non-spherical colliders as it is possible for one particle to be closer to the collider’s transform point while a different particle is actually hitting it one a far edge. I had a spherical collider, so it wasn’t a problem. Sorry, this is just some of my stock code.

One wacky idea I had was to instantiate a particle emitter when a particle hits something. The collision kills the orig particle and the instantiated emitter emits an identicle particle. Latch the instantiated emitter to the collider with a fixed joint. Set the fixed joint to have a very low break value. ie, slow movement wont dislodge it, but fast movement will and the snow will fall again. You could use the above code and a couple of lines like

var objectInstantiated = Instantiate(snowflake, closest, Quaternion.Identity);
objectInstantiated.GetComponent(FixedJoint).connectedBody = collision;

There is probably a way better way to implement that though. I am sure if you experiment you will find a solution. Although, I am starting to think it might be best to not even use particles…

Ok, so thats not possible with the world particle collider right now.

You can do it from scripting though. The world particle collider essentially does a raycast for each particle. In LateUpdate you should be able to cast a ray from particle.position-particle.velocity-deltaTIme to particle.position, to make them stop. Once they have landed you can apply your own custom behaviour per particle. For example you could just store all frozen particles in a particle emitter that is attched to the object you are colliding with.

Alternatively you could have a rigidbody per particle and in LateUpdate update the particle system array based on the rigidbodies.