Physics FAQ

Always remember that the Physicalize Behavior set the physics mode when it stops. When creating a physics setup it is really important to check that all triggers are set correctly. The easiest way to check if triggers are correct is to select a character in the viewport in order to activate the Visual Debug and open the Behavior Editor to see which behaviors are currently running or not.
 
Here is how to setup the physics in 5 easy steps to set the entities flying.
  1. Make them move using either Locomotion, Motion , Navigation... behaviors.
  2. Add the Physicalize Behavior in parallel with the current motions.
  3. Add a end trigger to start the physics and make sure the Parrallel operator will stop as soon as one behavior ends.
  4. Add a Force Behavior after the Parallel Operator and do not forget to set its Stop Trigger
  5. Add a Physicalize Behavior set to dephysicalize and set its Start Trigger condition

The Character Maker auto-computed physics properties do not always yield the best results, so it's better to spend a little time customizing them.

Check the complete tutorial about how to customize Physics Properties, Shapes and Angular Limits.

Before designing your behaviors, it is important to understand how physics simulation work. 

See the physics simulation world as a separate reality from the crowd simulation. It means that when a character is simulated with Golaem Crowd it may or may not be in the physics simulation world (actually it may even have only some body parts in the physics world).

So depending on which mode you have set with the Physicalize Behavior, each character (or character part) can be in on of the following states:

  • Only in the crowd world, not in the physics simulation world: when no Physicalize Behavior has been run yet, or if it has been dephysicalized
  • In the physics world, but controlled by classic behaviors (Motion, Locomotion...): when set to Kinematic Mode
  • In the physics world, but static; when set to Static Mode
  • In the physics world, controlled by physics simulation: when set to Dynamic Mode

It is important to understand that a physics simulation always aims at reaching an equilibrium in terms of collisions and applied forces. It is tempting to have characters in the crowd world, and switch to dynamic mode at the last moment when something happens. However it means that a character will suddenly pop in the physics world and can completely break this equilibrium and make physics simulation go crazy (exploding/flying characters).

In these cases, the best thing to do is to set every characters in Kinematic mode from the start of the simulation. It is a bit more time-consuming but it will ensure that when you switch your character to dynamic mode, the physics simulation solver will not be taken by surprise.

The physicalization/dephysicalization of an Entity only happens when the Physicalize behavior is stopped. Depending on the use case, a delay between the starting and the stopping of this behavior (with the Behavior Mode set to Physicalize and the Physicalize Mode set to Dynamic Rigid Body) should be respected:

  • If you need to keep the velocities from previous frames, the Physicalize Behavior should be stopped at least 2 frames after its start (use the Behavior Time Trigger to let the behavior stop after X frames).
  • If you do not care about previous speed (maybe because characters are not moving), you can start and stop the behavior at the same frame (use the True Trigger to let the behavior stop at the same frame than its start).

In the following example:

  • Green Characters have their Physicalize behavior which starts and stops at the same frame: speeds are not taken into account and they just fall on the floor.
  • Blue Characters have their Physicalize behavior which stops one frame after it starts: speeds are taken correctly into account, but acceleration is wrong which results into an unwanted force being generated. This is definitely not what you want.
  • Yellow Characters have their Physicalize behavior which stops two frames after it starts: speeds and accelerations are correctly taken into account

 

Activating the Bounding Boxes mode of the Physics Locator will display blue boxes around the physicalized characters in the Maya viewport. Otherwise it is impossible to know e.g if a character is in kinematic mode or not.

Either the joint limits are not configured correctly (open your character file in the character maker and check physics properties), or the force is really applied the same way on the whole body. In this later case, you can used body masks on the Force Behavior in order to get your characters to achieve different effects (e.g. apply force only on left part of body to get a rolling effect, or only on the head for a headshot...).

Guess what? Physics collision between two characters can only be detected if they are both in the physics world. For a character to be able to trigger a behavior using the physics collision trigger, it needs to be physicalized (at least in Kinematic mode)

First, remember that the physics collision trigger uses the bounding boxes of each physicalized limb to compute the collision, so it may starts behavior when characters are not exactly colliding but are very close.

However another frequent reason for a physics collision trigger unexpectedly starting is that if the crowd is dense and a lot of characters are already in Kinematic mode, they may be colliding a bit with each others. However you do not want all your soldiers to fall down each time they touch each others' pinky! That's why a filter has been added on the Physics Collision Trigger.

Usually what you want is to start your behavior when a kinematic mode character (walking soldier) is hit by a dynamic mode one (arrow, other soldier flying in the air...). In this case use the "collide with dynamic mode entities" filter on your Physics Collision Trigger.

If you want to control the position a a dynamic character (e.g. with maya fields, AdaptPosition behavior...) it is best not to put it's pelvis in Dynamic Mode (see Body Mask Attributes)

Have you clicked "Check Scene Settings" in the Crowd shelf  ?

Your linear working unit may not be set to centimeter.

Always remember when using Golaem that it will only works in this linear unit. When using another unit the simulation results might be totally weird due to extreme physics values applied to the characters.

Go into your scene preferences and change your working unit to centimeter. Do not forget to rebuild your simulation (CrowdManager , CrowdField and Terrain)

 

There is a limitation in Nvidia PhysX about the number of rigid bodies that can collide with another rigid body that makes the simulation unstable/crash.

Unfortunately, there is no easy way for Golaem to prevent from this crash, so whenever the total number of rigid bodies in the simulation exceed 65535, this warning is displayed:
"The number of rigid bodies in the simulation now exceed 65535. If a single AABB object collides with all of them, the physX simulation will crash. Please contact support@mayacrowd.com if you experience a crash after this message."

When this warning occurs, the physics simulation may become unstable, so it is recommended to split the simulation in several crowdfields where each crowdfield uses a different phsyX locator.

You have a very large scene with many entities in it and you would like to physicalize all of them but your scene keeps crashing every time you press play. Check your script editor, you should have this message popping.

When exceeded the number 65535 rigid bodies in your scene please pay extra attention to the Physics environment as your ground is maybe colliding with every entities

The workaround would consist in splitting this big Rigid Body into multiple geometries and to convert it into separate Crowd Rigid Bodies. The physical collisions will be much easier to compute. Also don't forget to put your Physics Locator Environment Mode to none.

Have you checked your character's Physics Shapes? Maybe your character has many physicalized bones which are overlapping, which results in physics instability.

Edit your character's ragdoll so each Physics Shapes overlaps with their direct neighbors only.

Your character should now fall naturally.

This usually is due to the way the environment or the rigid bodies were built.

First check that all your CrowdRigidBodies are mapped to the Physics locator used by your simulation.

If everything is good, then you need to optimise the way your rigid bodies are built, check this section of the documentation.