Game Development Community

Networking Help - Scriptable Motion Tree

by William Todd Scott · in Torque Game Engine · 03/27/2006 (4:40 pm) · 0 replies

Hi All,

I am working on adding a scriptable motion tree to the player class.

The idea is that a scripter could create a motion tree that would something like this:

new MotionTree(PsionMotion)
{
   new MotionBranch(Motions) {
      new MotionNode(LimpLeft) {
         new MotionConstraint(LeftLegInjured){};
         animation = LeftLimp;
      };
      new MotionNode(LimpRight) {
         new MotionConstraint(RightLegInjured){};
         animation = RightLimp;
      };
      new MotionNode(Walk) {
         animation = walk;
      };
   };
};

The player datablock would indicate that it uses the "PsionMotion" motion tree and the player class would loop through this decision tree at runtime to determine which animation to run.

The question I have is how to handle the client/server aspects of the motion tree. I was thinking of creating the motion tree as a simset (much like GuiControls) which would allow for the indicated scripting syntax. However, this would result in the motiontree only being created on the server side.

Can anyone suggest the proper way to handle this? I don't like the idea of having the motion tree only on the server side because then the player class can't properly estimate what it should do when there is network lag.

I don't believe I can create the motionTree as a datablock because I need the ability to nest the motions in script (which simsets provide).

I could write pack/unpack functions which would allow me to transfer the motiontree and rebuild it on the client when the player class is ghosted...

edit: Or, I could execute the motionTree script on both the client and the server so that the motion tree exists in both cases. The datablock could then store the name of the motion tree and use findObject() to get the actual object.

Any suggestions (or code that you think I should review) are much appreciated.

GG: It was great meeting you guys face-to-face at GDC!

Todd