All Classes Namespaces Functions Variables Enumerations Properties Pages
Behaviours

The Puppet Behaviours are classes that inherit from the abstract BehaviourBase.cs and that's main idea is to provide a pattern for developing functionalities that dynamically adjust muscle and pin weights, strength and other properties or make kinematic adjustments to the target pose. The most important Puppet Behaviour is the BehaviourPuppet.cs that handles the pinning of Puppets to target animation, releasing those pins in case of collision and re-tightening them when getting up from the ground. The Puppet Behaviours can be switched, for example when the BehaviourPuppet loses balance, it can theoretically switch to BehaviourCatchFall or BehaviourWindmill (both missing from the initial release, but will be developed in the future). The Puppet Behaviours are designed so tha they would not contain a single external object reference. That means they can be simply duplicated and moved to another Puppet.

Behaviours2.png


Switching Behaviours:

When working with multiple Behaviours, keep only the one that is supposed to run first enabled in the Editor. For example when you have the BehaviourPuppet and BehaviourFall, keep the former enabled and the latter disabled if you wish for the Puppet to start from normal animated state, not falling.

Switching between behaviours by code must be done by calling BehaviourBase.Activate(); on the Behaviour you wish to switch to. All other Behaviours will be disabled.


Events

Behaviours trigger events on certain occasions (such as losing balance). They can be used to get a message through to your own scripts or switching behaviours.

PuppetEvent.png


Sub-Behaviours:

Sub-behaviours are reusable self-contained chunks of functionaly that can be easily shared between multiple Puppet Behaviours. For example SubBehaviourCOM is a module that automatically calculates and updates center of mass related information for the Puppet - data such as center or pressure, direction and angle of the COM vector and detect if the Puppet is grounded or not. This prevents the necessity to duplicate code for all the Behaviours that need to make COM calculations. To see how to use a sub-behaviour like that, take a look at the section below and the BehaviourTemplate.cs class.


Creating Custom Behaviours:

PuppetMaster has been built from start up with customization and extendibility in mind. To create reusable behaviours of your own, make a class that extends the BehaviourBase abstract class or just make a copy or BehaviourTemplate.cs and start adding functionality following the pattern at hand.