bw logo

Chapter 4. Models and Animation

4.1. Pilot models

To display characters seated in or on the vehicle, use the entity's model as an attachment. Entities themselves cannot be used as attachments, so you will need to remove the model first, and then attach it to a hard point on the vehicle.

pilotModel = self.pilotAvatar.model    # hold the model with a local
self.pilotAvatar.model = None          # detach model from entity
self.model.mount = pilotModel          # attach model to hard point

For each seat in the vehicle, you will need a separate hard point, and a corresponding hard point in the avatar's model.

4.2. Animating the vehicle

Controlling the animations of passengers and vehicles is likely to be very vehicle-specific, and so might be implemented in script on a per-vehicle basis, rather than using the Action Matcher.

In the Ripper example, a simple Action Matcher is implemented using lists of single frame and transition animations. A method called during the hover vehicle physics tick, PlayerRipper.checkAnims(), manages the ripper's animation in flight.

 vehicleActions = [ "RIdle",
                    "RTurnLeft",
                    "RTurnRight",
                    "Stop",
                    "Thrust" ]

  def checkAnims( self ):
     ...

     if self.wantTurn != 0:
         act = (self.wantTurn+1)/2 + 1
     elif self.wantMove != 0:
         act = (self.wantMove+1)/2 + 3
     else:
         act = 0

     act = int(act)

     ripperAction = self.model.action(Ripper.vehicleActions[act])
     ripperAction()
    ...

client/Ripper.py