7. Game Logic

When adding game logic to your character, make sure to put the game logic on the armature object itself, rather than on the mesh.

If you are making your character a dynamic physics object, you may need to adjust the center point of the armature based on the size of the dynamic object to make sure that the character's feet touch the floor. The character's feet should touch the bottom of the dotted dynamic object sphere (Figure 22-17).

Figure 22-17. Dynamic object for the character

Generally speaking, you will need to add an Action Actuator for each different action that your character can perform. For each actuator, you will need to set the start and end frames of the animation, as well as the name of the action.

Since version 2.21, Blender has the ability to create smooth transitions or to blend between different game actions. This makes the motion of game characters appear much more natural and avoids motion "popping". To access this functionality, all you have to do is adjust the "Blending" parameter in the Action actuator. This field specifies how long it will take to blend from the previous action to the current one and is measured in animation frames. A value of "0" indicates that no blending should occur. Note that this blending effect is only visible in the game engine when the game is run (Figure 22-18).

Figure 22-18. Blending Actions

Action actuators have many of the same playback modes as Ipo actuators, including looping, playing, flippers and property- driven playback.

You should try and design your game logic so that only one action is triggered at a time. When multiple actions are active at the same time, the game engine can only display one of them on any given frame. To help resolve ambiguity, you can use the "Priority" field in the action actuator. Actions with lower numbers will override actions with higher numbers.