Physics with animated colliders

Local Servo Rigid Body is a Physicalize Mode which has been featured since Golaem 4.2.1

It allows you to play animations on physicalized entities which was impossible before. Here is a basic setup to test it.

PREPARING YOUR SCENE FOR PHYSICS

To achieve better physics simulation when it comes to collision between entities and rigid bodies, multiply the frequency. To do so go inside the maya preference window and under the Settings tab change the Time to 60 fps. This way the collisions will be detected quicker and though will be more accurate. Inside the Time slider Tab change the Playback speed to Real-time 60 fps.

After changing these settings, make sure that the first frame of the time slider range is 1, otherwise, you may skip the simulation initialization when playing.

CREATE A TERRAIN

1. Create a pPlane, select it and click on the Terrain icon  to create a Terrain Locator.

CREATE THE COLLIDER

2. At the center of the scene create a Cube and scale to give it a the shape an horizontal bar.

3. Select this Box and inside its channel editor create an expression on the Rotate Y channel to make it spin: pCube1.rotateY=time*50

4. Still keeping the Collider selected click on the Crowd Rigid Body icon .  Leave the attributes as they are. 

5. When creating a Crowd Rigid Body, you will notice that Golaem automatically added a Physics Locator  in your scene. Because we already increased the scene fps, we do not really need physics to have a lot of substeps in one frame, so let's set its Physics Substep to 2 instead of 3.

PLACE YOUR PARTICLES

6. Create an EntityType  and browse to find the Character File (.gcha) in the /crowd/characters directory of the Samples Pack.

7. Click on the Population Tool icon  and then click at one side of the bar collider to place a Population Tool Locator.

8. Adjust at your will the Population Tool parameters in the Attribute Editor. Edit the orientation to make them face their future collider.

9. Click on the Create button to create a particle system and link it to a Crowd Field to instanciate characters on top of your particles.

10. Click the play button to visualize the created characters. They are not moving yet.

Obviously if your characters are orange, you may need to import the shaders in your scene (see Quickstart)

ANIMATE THE CHARACTERS

11. Open the Behavior Editor  and double-click on the entityTypeShape1

12. Drag and drop a Motion Behavior  and load the Run motion provided in the character Pack.

 

13. Play your simulation, your entities now go to the target but pass through the bar, they are not in the Physical world yet.

PHYSICALIZE YOUR ENTITIES

14. Inside the Behavior Editor drag and drop a Behavior Container   on top of the Motion Behavior in order to create a Parrallel Operator with both nodes.

15. Drag and drop a Physicalize Behavior  inside the Container 

15. Go inside its attributes and set its Physicalize Mode in Kinematic Rigid Body. It is a recommended practice when playing with physics that characters are set to Kinematic Rigid Body mode at the begining of the scene, so that they do not suddenly pop into the physics world when switched to another mode.

16. Unlike the other behaviors, the Physicalize Mode mode of an Entity only happens when the behavior is stopped, double-click on the Stop Trigger of the Physicalize Behavior to edit it in the Trigger Editor, select the True/False node and set it to True in the Attribute Editor so that the Physicalize Behavior stop at once. Plus, here we need the character to actually be in the physics world to be able to detect collisions.

17. Drag and drop another Physicalize Behavior on the Behavior Flow (after the first one).

18. Go inside the attributes of this Physicalize Behavior and change the Physicalize Mode to Local Servo Rigid Body.

19. We want this behavior to stop (remember physics mode is only set when the behavior stops) when a collision occurs. Double-click on its stop trigger to edit it. Drag and drop a Collision Trigger and sets its attributes to Rigid Body ID = 0. Do not forget to right-click on the added trigger and set it as root trigger so that it is evaluated.

20. Play your simulation.