Particle tips DealingWithAttractors

From PopcornFX
Jump to navigation Jump to search

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

The new Attractor evolver Attractor evolver and localspace evolver Localspace evolver now allow the creation of shape attractors.

By default, the attractor will treat the attraction shapes as being in worldspace.
Using localspace evolvers allow you to move these attraction shapes in the FX instance's space, and have local attractors.

Common pitfalls

Simulation blow-up

Even when using the 'Stable' mode of the Physics evolver Physics evolver, when using attractors, the simulation might blow-up. This is because the force field is evaluated once per frame, at a discrete location.

Sluggish or excessively low framerate will blow-up the sim and introduce inconsistencies. To avoid this, you can activate sub-step evolves.

To do this, click on the particle state in the treeview, and tweak the following properties:

  • 'MicroUpdatesMinFPS' : minimum number of updates per second this state should run at.
  • 'MaxMicroUpdatesPerFrame' : maximum number of sub-steps acceptable (to avoid the simulation going down a vicious circles of more updates causing slower framerate causing more updates causing slower framerate, etc...

Particle state : tweaking micro-updates

For more details on tweaking the micro-updates, see the micro-updates section in the evolve state page.

Mesh attractors

Mesh attractors use the same code as the projection evolver, therefore, suffer quite a bit with particles that are not on the surface of the attractor (ie: in an attractor scenario, probably ALL particles), and is pretty imprecise. Therefore, avoid using meshes with the attractor.
This is something we'd like to fix in the future when we get the chance, or if it is really wanted by the community :)

Attractors and the 'Force' field

The attractor evolver overwrites its output 'Force' field with the new value, it does not accumulate it. Therefore, if you need to combine the forces coming from other sources to the ones from the attractor, you'll need to use an intermediate Force field

Multiple attractors

With multiple attractors in the same evolve state, each one will overwrite the Force computed by the other ones. So, there are multiple options:

1- Use a single attractor with a shape collection instead of multiple attractors with a single shape each

2- Evaluate each attractor in a separate 'Force' field, and accumulate the forces inside an evolve script:

  • Attractor 1 writes in the field "Force"
  • Attractor 2 writes in the field "Force2"
  • Attractor 3 writes in the field "Force3"
  • write an evolve script that does:
Force += Force2 + Force3;
Force = Force + Force2 + Force3;
to accumulate the 3 forces into the field "Force", that will be used by the physics evolver afterwards.

Local or not local?

By default, when adding an attractor evolver, the shapes will be in worldspace, and all instances will be affected by the same shapes.

Fully local effect

For each instance to have its own set of local shapes, you need to drop the attractor evolver inside a localspace evolver Localspace evolver :

Attractor evolver inside localspace evolver

This will also cause the whole effect to become localspace, the particles following the source instance as it moves around.

Local attractor, world particles

This might not be a desired effect. If you want your particles to stay in worldspace but have local attractors, you will need to change the localspace evolver Localspace evolver settings to tell it not to take into account the previous => current frame transforms of the instance:

Default localspace settings
Default settings

Localspace settings for local sub-evolves with world particles
Settings for local sub-evolves with world particles

Using the previous => current transform mode will apply the movement offsets of the original instance to all its child particles, effectively making them move around with it.
Using the current => current transform mode will not apply any offset and leave the particles as they are, but will still allow the sub-evolvers to run in localspace.