Particle tips LocalShapeColliders

From PopcornFX
Jump to: navigation, search

For PK-Fx Editor version : 1.5.3 and above
Main page: Particle tutorials


The new collisions evolver Collisions and localspace evolver Localspace evolvers now allow the creation of particles that collide with local shapes.

Before v1.5.3, the only collisions available were full-scene collisions through user collision callbacks that had to be hooked on the C++ API side to your own game engine's collisions functions.
You can now specify a custom shape if you don't need your particles to collide with the full scene.


By default, the particles will collide with the shapes in worldspace. For example, you can use a mesh shape of your level to use popcorn's fast batched particle/mesh collisions, if your physics engine doesn't expose batched raycast queries.

Using localspace evolvers allow you to move these collisions in the FX instance's space, and have local colliders.


We'll start with a particle rig that emits a bunch of particles from a shape cube, falling down due to gravity:


base rig



Create a new shape sampler we'll use as the collision shape. Here, a sphere :

collision shape collision shape



Add a new collisions evolver CParticleEvolver_Collisions. By default, it will behave like the physics evolver, and collide with your ingame scene if the C++ popcorn API was hooked to your game engine.

To make it collide with the newly created shape, Set the 'Collider' property to the shape you want to collide with (Note: this can be a shape collection).
To clear the shape collider, just click on the 'Reset to default' square between 'Collider' and the dropdown.


shape binding


You should see the particles collide and bounce on the shape:

shape collision


Set the 'BouncesBeforeDeath' to a large value to stop the particles from being killed after the first bounce:

bounce count

shape collision large # of bounces



Now, as is, the particles collide with the shape in worldspace. To better visualize this, add a backdrop, and spawn other instances of the effect on the sides of the collision shape:

As you see, the different instances do not have their own version of the shape translated to where the FX instance is, they all collide with the same shape, at absolute position = {0,0,0}


worldspace collides worldspace collides



To fix this, create a new localspace evolver CParticleEvolver_Localspace, and drag/drop both the Physics and Collisions evolvers INSIDE it:

evolver localspace: before

evolver localspace: after



This will make both the physics and collisions evolver run in the instance's local space, and you can now see each instance seems to have its own version of the collision shape:

local collisions

local collisions