Lemmings example file

This example shows how simple flocking can be accomplished using the Follow and Interact POPs.

The single leader particle is birthed on the first frame. Its position is set from the transform channels of the object “leader” which is a good example of how to explicitly animate a single particle “by hand.”

The followers are birthed from a grid also only on the first frame. In order for the Interact POP to know how large the instanced geometry is, an Instance POP is used to place geometry on the particle. The instanced geometry will be the render SOP from the “bird” object.

To keep the followers from bumping into each other, an Interact POP is used. This POP applies inter-particle repulsive forces. The influence type used is “Effect Intersects Effect” to allow maximum buffering between the instanced geometries.

The Interact POP pretends there is a sphere of influence around each particle. This sphere has two parts: the particle radius which represents where the instanced geometry should be and the effect radius, which represents a further buffering area. The amount of applied force is constant throughout the particle radius and is an inverse cosine over the effect radius. In this example, we use 5 times the instanced geometry size for increased stability. A force multiplier of 10 is used to make the repulsion effect more immediate.

A Follow POP is then used to make the followers follow the leader particle. Since the leader particle has no real velocity (i.e. its velocity attribute is 0 and its position is manipulated), the ambient speed must be used. This represents how quickly the followers will try to follow the leader.

Try bypassing the Interact POP to watch the followers collapse among themselves. Play with the scales of follow1 and interact1 to observe the effect. Play with the particle radii of interact1 and see what happens. Remember you can toggle the guide geometry flag on to see a visual representation of the applied force.