Select the particle_emitter and Simulate > ICE > Create menu choose Emit Particles from Selection… With the PointCloud still selected, press [Alt] + [9] to open an ICE Tree. Before you can assign any goal or paths for the particles you have to choose a criterion to use to separate the particles. In this example you’ll be using three different objects so it makes sense to divide the particles into three groups, one for each goal/curve. As each particle is born it’s also assigned a unique identification or ID. By feeding this ID into a Modulo operation and set the devisor to the same value as the number of groups you want to create, you’ve efficiently created the 3 collections.
Get a Get Point ID, a Modulo and a Set Data node. Connect the Point ID to the Value input of the Modulo node. Double-click on the Modulo node to open its PPG and set the Modulo By to 3. Connect the Result of the Modulo node to the Value input of the Set Data node. Open the Set Data node’s PPG and in the reference textbox enter self.Goal_ID. This creates a custom variable where each particle is assigned the result from the Modulo node (which is one of three numbers 0, 1 or 2). Connect the Execute port of the Set Data node to the Execute on emit1 input of the Emit from Surface node.
Get a Get Data node and a Select Case node. Open the Set Data PPG and enter self.Goal_ID in the text box and close the PPG. Connect the Value port of the Get Data node to the Condition input of the Select Case node and the Select Case node to the Port2 input of the ICETree node.
Press [8] to open an Explorer. Select the goal object and the two curves and drag and drop them into the ICE Tree. Get a Move Towards Goal node and connect it to the Case0 input of the Select Case node. Connect the Value port of the Goal_No1 node to the Geometry1 input of the Move Towards Goal node. Get two Flow Along Curve node and connect the each Curve node to the Curve1 input of their respective Flow Along Curve node. Connect the execute port of the first Flow along Curve node to the New (Case0)… input of the Select Case node and the second Flow along Curve node to the New (Case1)… input.
The project files used in this tutorial can be found at:
http://www.redi-vivus.com/Caffeineabuse/Multiple_Goals.zip
Image 01
Rather than staking numerous If or Filter nodes, the Select Case node can be used as an efficient way to execute different tasks based on conditions
Image 02
Becoming acquaintance with the Modulo operator will save you a lot of time whenever you need to separate particles into different group or collections.
Quick tip
If you’re using multiple goal objects, replace the Move Toward Goal node with a Set Particle Goal node. On the ICETree node, right click on the Port3 and from the menu choose Insert Port Before to insert a new port. Get a Move Towards Goal node and connect it to the Port3 input of the ICETree node. This way you can control all the particles within a single node even though they have separate goals.
Read the full post>>