Particles with Collision

From Runic Games Wiki
Jump to: navigation, search

In this tutorial we'll use the Plane Collision affector to make particles bounce when they collide with the ground. This is how effects like barrel staves and skeleton bones bouncing away are created in Torchlight 2.

If you have trouble following this tutorial, try running through this one first: Your First Particle System

Lets start by making a basic particle system, which emits particles that shoot upward and then fall back down. Create a Particle, and change these properties:

  • Set the particle's Texture to: media\particles\Textures\Glowglow_aura_bright.dds
  • Change the Render Style to additive

Then, add an emitter and change these properties:

  • Make ParticleLife random from 1 to 3
  • Set Velocity to random 2 to 6
  • Set Angle to random from 20 to 60. This will make the particles shoot out in a cone of between 20 to 60 degrees, and none will shoot straight up.

Go ahead and hit the green play arrow to see what we have, a bunch of white dots flying up into space.

Tut-04-01.jpg


Now, add a linear force affector to make the particles fall. Under Forces, set its Y property to -4.

Finally, add a Plane Collision affector. As soon as you add it, you'll see your particles start to collide with the ground and bounce away. You can control their movement by adjusting the Bouncyness and Friction properties. Intersection should probably always be left on Fast, but try changing Type to Flow and see what happens.

In the editor, particles will always collide with the Working Plane, the height of which you can adjust in options, but in game they can actually collide with the ground and bounce down stairs. To make them do that, change the Use Ground property of the Plane Collision affector to True. You won't be able to see any change in the editor when you set that, but it will show up in game. Make sure the Keep Local property on the Emitter is set to False.

That's all you have to do to make your particles bounce on the ground. The system we've made with bouncing white dots isn't much to look at, but you can use the basic idea to make bouncing sparks, rocks, or spell effects. Try it out and see what you come up with!

Tut-04-02.jpg


It may be tempting to make a whole river of particles that flow through the hills of your level, but try to use these sparingly. Particles that collide with the ground a lot more expensive than those that don't, and if you have a lot of them they can hurt performance. Consider changing the Quality property on the Particle to Medium or High on particles with collision, so that people with slower machines can lower their settings in-game and not see them.

Other Types of Particle Collision

There are a few other particle collision affectors:

  • Box Collision
  • Sphere Collision
  • Collision Avoidance

I recommend avoiding all of these. None of them are used in any particle system in Torchlight 2. Box and Sphere collision are just too expensive, and I never found a use for them that looked cool without using a large number of particles. Collision avoidance makes particles avoid each other and might actually be pretty useful, but it was exposed late in the project and didn't get any real testing.

If you're creative you may find a great use for these, but keep an eye on your frame-rate.

Personal tools
Namespaces

Variants
Actions
Navigation
Runic Sites
Toolbox