Tips & Tricks
Tips
- You can change the excitation of multiple muscles together by selecting them simultaneously and adjusting the the Excitation field slider under the Muscle Stimulator component.
- When attempting to work on specific muscles in isolation, it sometimes helps to pin Rigidbody components you’re not working with by setting their Is Kinematic fields to
true
.
Caveats
- Muscles still exert passive effects even without activation, so joint torques still need be calculated for all muscles regardless of activation level to get the full effect.
- The
muscleNodes
field inMuscleTendonUnit
expects muscle nodes to be defined in order from muscle origin to insertion. This ordering implicitly encodes the direction of muscle contraction (which begins with the insertion and moves toward the origin). - For those from a more traditional academic background who might be unfamiliar, Unity uses a left-handed coordinate system. Keep in mind that rotations therefore follow the same principle.
- Try not to assign too much meaning to any particular paramater value or put too much stock in finding real-world reference values. The parameters and configurations you use are what they are and will be what they need to be.
Troubleshooting Muscle Movement
This is a big topics since Unity physics has a lot of parts to it. Rigidbody, Joint, Muscle Node, and Muscle Tendon Unit configurations all affect body and muscle behavior, and there are many reasons why muscles may fail to behave as anticipated including flawed expectations. I’ve created an initial checklist from issues that I’ve encountered:
-
Make sure that each muscle node
Bone
field references the actualGameObject
that you want to attach to. Errors can easily be made if you use the Object Picker interface and have objects that share the same name. -
Following from the above, do a check in the Scene View from all angles that your muscle nodes are in their intended positions. The muscle torques being generated can be very sensitive to muscle node placement.
-
A muscle node configuration that behaves acceptably in one body position can produce unintended movement once rotated far enough into another configuration. You can of course run simulations and observe the resulting behaviors, but it can help to first inspect muscles while rotating limbs around in the Scene View to check that they won’t enter an obviously undesirable configuration.
-
Check the Unity Joint and ragdoll stability page.
-
Ensure that the global 3D physics settings are set as you want them, such as Default Max Angular Speed. To find these settings, navigate to Edit > Project Settings > Physics.
-
If your rigid bodies seem a bit too sensitive or a bit too resistive to movement under muscle activation, you may need to manually adjust their inertia tensors.
-
Check the configurations on the Rigidbody components. Make sure that:
- The Mass value isn’t too high relative to the maximum isometric force of the muscles moving the rigid body.
- Drag and Angular Drag aren’t set too high. Otherwise, the muscles will have trouble overcoming the movement resistance.
- Is Kinematic is not checked. If it is, physics won’t affect the rigid body.
- Use Gravity is set as intended. Muscles behave very differently under gravity versus without. Turning off gravity on rigid bodies can be useful sometimes for debugging, but don’t forget the context of your results.
- Joint constraints are set as intended. Make sure you didn’t accidentally leave any of the Freeze Position or Freeze Rotation coordinate-axes flags on if you didn’t intend to.
-
Check the configurations of the Joint components involved in the motion. In particular:
- Make sure that the angular limits allow or restrict the movements that you expect to be allowed or restricted.
- Double-check that the Connected Body field is properly set on each Joint component.
-
If you’re using Is Kinematic to pin rigid bodies while testing, be aware that motions may involve a broader combination of muscles, bodies, and joints than you might understand. Restricting movement in specific parts can effect movement in adjacent areas.
-
On muscles, check the values for the following fields:
- Normalized SEE Slack Length affects the length ratio of the “passive” serial elastic element to the “active” contractile element. Setting this value higher makes the muscle more elastic and less responsive, potentially getting more noticeable oscillatory behavior. This also makes the muscle’s passive effects more pronounced, so a muscle with a high normalized SEE slack length value can powerfully inhibit the movement of antagonist muscles.
- Max Isometric Force affects the overall magnitude of the torques generated by the muscle. If this value is set too low, the muscle will be ineffective in driving motion. If this value is set too high, it’s usually pretty obvious.