This post was originally writtenon July 2018
Background, in 2018, I did a Houdini certification at NYP in Singapore.
The assignment brief:
Flipper is a game character that has been animated to move in a circular path, along the ground which is colored in patches of red and blue
Much like in a computer game, as Flipper moves along the ground and touches the RED areas, he will score points in the form of coins or balls that will emit from the contact areas. These coins will bounce a few times and settle on the ground.
As Flipper returns the second time, he will ‘collect’ these coins. The coins will be ‘sucked’ into him when he comes near them.
Bonus : Much like a game, display the number of coins collected at the top right of your camera. Use the font SOP to create this.
The simulation is divided in two parts. The challenge in part 1 was how to detect the red zone and only emit from those points when Flipper passes over them. They are multiple ways to approach the problem, but one of the simplest solution was:
Get the intersection between the rubber toy and the ground.
Add some thickness and scatter points along the intersection.
Transfer the color attributes from the ground to the points.
Delete any points that are not red.
The remaining points would then be the emitters.
Transitioning between part 1 and part 2 was another challenge. You want to stop Flipper emitting particles before he starts attracting them and you don’t want it to suck back the particles as soon as they were emitted. I ended up going with a “hard coded” solution instead of having a fully procedural one so there is room for improvement.
I ended up deleting the emitter points at frame 71 when Flipper is done doing its first lap.
Because the particles network (Popnet) still exist, the already emitted particles stay there.
The second part involve creating a force that would push the particles to Flipper when it is close to them. This part was probably the easiest one to do but keeping good controls over the simulation was a little bit tricky. We first need to create the suction force.
To get the suction force, we need to calculate the distance between a particle and Flipper.
Then, we need to establish the conditions for when the suction is applied.
The distance between Flipper and the particles needs to be under a certain number.
The frame should be past 71 (when Flipper is done emitting).
Finally, we need to set what happens to the particles when they are sucked back to Flipper. My first reflex was to kill the particles when the distance between Flipper and the particle is below a certain number, but because we want to keep track of the score, we cannot kill them inside the simulation. Instead, I am using a collision detection node.
With the particle collision detect node, I can keep track of the particles that were absorbed by Flipper, but I can also group them.
Outside the simulation, you can then delete the group so they don’t stay visible.
With a Font node, you can then read the collision number to show the score.
I replaced the particles by coins to add context to the simulation. The coins were also falling without rotating because their orientation follows their normals. I used their velocity as their normals instead so they can fall in a more natural way.