Unity3D: constraining particles

What if you need to keep your particles in line, like creating a stream of water which flows exactly inside the tube, or (in my case) steam from a locomotive that does not leave the tunnel through the solid roof? The solution is so elementary, you’ll flip when you see it.

Screen Shot 2014-03-13 at 10.34.57

This is what it looks like with unconstrained particles. There’s a steaming locomotive in this depot and it looks bad. It looks especially bad on mobiles, ’cause soft particles feature is deferred lighting only and DL will kill performance even on iPhone 5s (proven).

Screen Shot 2014-03-13 at 10.36.00Now take a look at the Shuriken Particle System inspector, especially Collision tab. You may have seen it but never gave it any thought or realized how the shit works. I know I did.

When Collision tab enabled, Shuriken applies same rules to every particle that contacts any collider. For example, Dampen value will be applied on contact, slowing your particles down. Bounce will, well, bounce them off. Lifetime loss will shorten lifetime of a particle, apparently. And if Min Kill Speed is zero, your particle will be just destroyed on contact.

Screen Shot 2014-03-13 at 10.35.34

That’s exactly what I did – added a flat thin box collider just under the roof. Notice steam still coming up from below roof but not through it?

Fucking magic.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: