Setting the scene

Start with a new scene ([ctrl]+[X]) and make sure the default cube is selected. In the Link and Materials panel of the Editing menu [F9], change its name in the OB: field to something more relevant, like: Prey. Move it somewhere else in your scene ([G] key in any viewport you prefer).

Then add a new Cube: [Space] > Add > Mesh > Cube. The same way as before, rename it something like: Predator and move it on the other side of your scene. Using the [S] key, give it a greater size than the prey cube (SixeX = SizeY = SizeZ = 5.0 for example).

set scene

Setting the particles systems

The Prey particles

Select the Prey cube. In the Object menu [F7], in the Particles buttons, click on the Add New button of the Particle System panel. Change a few of the values:

  • Amount: 100 in order to set a flock of 100 prey particles
  • Life: 1500 in order to give each particle a lifetime enough for the prey-predatory simulation to work

Let now decide how the prey particles will appear: in the Visualization panel, make sure particle are shown like Point and give them a Draw Size of 3 (size of the particles in the 3D viewport). We want the Preys to be small, so in the Extras panel, set Size to 0.3 (actual size of the particle during the simulation; will help preys to keep near each other). Also, it's time to activate the Die on hit option, because we want these particles to disappear when they are reached by the Predator particles.

Now, we need to give the particles rules to follow. In the Physics panel, choose Boids in the dropdown menu as the particles system type, and adjust its Physics in order to make the preys a little slower than the predators (giving them some speed advantage over the preys) by lowering MaxVelocity to 7.000. It is not necessary to update any of the rules values, as we are trying to set a very simple simulation.

prey settings

The Predator particles

Now, select the Predator cube. In the Object menu [F7], in the Particles buttons, click on the Add New button of the Particle System panel. Change a few of the values:

  • Amount: 10 in order to set a flock of 10 predator particles
  • Life: 1500 in order to give each particle a lifetime enough for the prey-predatory simulation to work

To ease the understanding of the simulation, in the Visualization panel, select Cross instead of Point and give them a Draw Size of 10. As we want the predators to more easily "eat" the prey particles, set the particle Size to a greater value, like 1.5, which means that is a prey enters the predator particle radius, it is eaten. Because the prey particle is set to Die on hit, it then simply disappear.

And now, the most interesting part of this simulation: in the Physics panel, choose Boids in the dropdown menu as the particles system type, and adjust its Behaviour parameters as follow:

  • Goal: 1.500 in order to enhance goal seeking
  • Crowd: 1.00 in order to enhance crowd avoidance
  • Collision: 0.500
  • Avoid: 0.500
  • All other: 0.100-0.250

and move the Goal and Crowd priorities upward in the list of rules using the little up and down arrows in front of each rule.

Predators are especially efficient in hunting. To reflect that, make sure that MaxVelocity (by default 10.000) is higher than the prey's (7.000 if you followed the tutorial) and set a higher AvVelocity too (for example, 0.500 vs 0.300 for the preys). Also, still to give predators some advantages over the preys, give them a better TangAcc (for example, 0.500 vs 0.200 for the preys). Finally, decrease the flock size to something like N 3 so that the predators become able to hunt in small groups.

predator settings

Setting the fields: how do they really work?

Now we are almost done. Select the Prey cube emitter and in the Physics buttons, in the Fields panel, choose PSys instead of Object and set a Spherical field for it with a positive Strength of 2.000. Then select the Predator cube emitter and, also in the Fields panel, choose PSys.001 instead of Object, and set a Spherical field with a negative Strength of -10.000 and a Fall-off of 2.000.

Basically, the positive value will tell to all other boids particles of the scene that these particles are preys which predators would find apetizing and try to catch because of their 2.000 weight. With the same idea, the negative value will inform all other boids that those particles are very dangerous predators because of a weight value of -10.000 and that any prey particles in the vicinity should really try to avoid them very hard!

The Fall-off works exactly like the fall-off from classical fields. For example, when a predator is far away, the prey particle will almost not notice it, because the fall-off makes the field too weak beyond a given distance. The closer the predator gets, the stronger the field effect will become, increasing the urge of the prey to flee away from the predator once it has become closer. The max distance setting can also be very usefull here, because thanks to it, a predator can get really close to its prey without being detected until the max distance is reached and the prey "alarm" is triggered.

Playing the simulation

The only thing else you have to do is to set the simulation length. This mostly can be done in the Anim tab of the Render buttons, in the Scene menu [F10]: you just have to set the End button to a greater value, like 1000-1500, according to the Life duration of the particles and a few try-and-guess simulations. If you need to adjust the particles Life duration, then Clear the cache beforehand in the Particles System panel. When you are ready to play the simulation, just do a [ALT]+[A] with the mouse cursor in the viewport of your choice, and use [ESC] to put the simulation to an end.