Game Development Community

Moving DTS on a Path

by JW · in Torque Game Engine · 03/23/2005 (7:35 am) · 17 replies

I am able to run a DTS animation (Flag tutorial) and have a some bit of knowledge on how the sequence in DTS works.

Is it possible to move a DTS object on a path node? (The DTS object has animation sequences in it and is not an AIPlayer)

Do I need to make the changes in engine or can this be done through script files? Have looked on tutotials/ resources but didn't get much help.

#1
03/23/2005 (7:45 am)
It is doable without modify the engine, just scripts, check this one from bravetree:
http://www.garagegames.com/products/19
i got this pack a while back, there is a animated bird follow the path ...

and there is a resource close to what you are looking for:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6673

hope this helps.
#2
03/23/2005 (7:54 am)
@Kefan

Thanks for pointing to the resource. The second resource is about making the Bots (AIPlayer) follow you but my DTS objects are not bots as they are simple animations.

The animated bird sounds interesting, is there a resource/article that can provide more light on the subject.
#3
03/23/2005 (9:36 am)
I think DTS object follow the path , should do the same as bots follow
path, just different object.
for anything "follow a path", you need a "loop" keep the DTS busy, and
an "marker" tells where is next "marker" to reach, and that what is the second
resource already provided:
function AIPlayer::think is the loop function, tells you how to implemetn
"setMoveDestination"

once the DTS object collide with the "marker", then you can use (need some
modification ) this function:
function HealthPatch::onCollision(%this,%obj,%col)
for telling the DTS object, what should do next ( goto next "marker").

this just what i think in theory, i did not code this myself.
#4
04/10/2005 (11:39 pm)
Sorry, @Kefan; got busy in some other high priority stuff, didn't try what you referred to but it sounds interesting. Will work on this today and post the result if things work fine. Thanks
#5
04/11/2005 (7:23 am)
Not working. Will require some help.

The "setMoveDestination" function that is doing the task of setting the various variables and tells the AIPlayer to move to the location provided is not available for DTS objects that are extended from Static Shape.

I am able to spawn DTS object on a Node but not able to move to next node.
#6
04/11/2005 (7:37 am)
You will probably want to re-implement the specific functionality in the class that you are using.
#7
04/11/2005 (7:42 am)
Actually that would be alot more complex than just using a static .dts as the ShapeFile for a new AIPlayer.
#8
04/11/2005 (8:08 am)
Thanks @Stephen. Can you also clarify the following:
- do i need to have the same and all nodes as an AIPlayer has or it doesn't matter?
- i was planning to move the Flagpole.dts file on path nodes; and as it is not an object of Player/AIPlayer, can I still give it some AI to run as per the terrain?
#9
04/11/2005 (8:26 am)
Thanks @Dreamer. U mean, I can replace the .DTS file of a new AIPlayer with flagpole.dts? How to do this? Changing in the datablock doesn't help (hope I changed it correctly).
#10
04/11/2005 (8:51 am)
Create a new body type based on the current AIPlayer and replace the shapefile name with the .dts you want to use. I did this to create mimicks (treasure chests that attack).

datablock PlayerData(MimickBody)
{
   renderFirstPerson = false;
   emap = true;
   
   className = Armor;
   shapeFile = "~/data/shapes/boxes/treasurechest.dts";
   cameraMaxDist = 3;
   computeCRC = true;
  
   canObserve = true;
   cmdCategory = "Clients";

   cameraDefaultFov = 90.0;
   cameraMinFov = 5.0;
   cameraMaxFov = 120.0;
   
   aiAvoidThis = true;

   minLookAngle = -1.4;
   maxLookAngle = 1.4;
   maxFreelookAngle = 3.0;

   mass = 20;
   drag = 0.1;
   maxdrag = 0.4;
   density = 6;
   maxDamage = 100;
   maxEnergy =  60;
   repairRate = 0.33;
   energyPerDamagePoint = 75.0;

   rechargeRate = 0.256;

   runForce = 100 * 90;
   runEnergyDrain = 0;
   minRunEnergy = 0;
   maxForwardSpeed = 20;
   maxBackwardSpeed = 13;
   maxSideSpeed = 13;

   maxUnderwaterForwardSpeed = 20;
   maxUnderwaterBackwardSpeed = 7.8;
   maxUnderwaterSideSpeed = 17;

   jumpForce = 8.3 * 90;
   jumpEnergyDrain = 0;
   minJumpEnergy = 0;
   jumpDelay = 15;

   recoverDelay = 9;
   recoverRunForceScale = 1.2;

   minImpactSpeed = 45;
   speedDamageScale = 0.4;

   boundingBox = "5 5 5";
   //boundingBox = "";
   pickupRadius = 2;
   
   // Damage location details
   boxNormalHeadPercentage       = 0.83;
   boxNormalTorsoPercentage      = 0.49;
   boxHeadLeftPercentage         = 0;
   boxHeadRightPercentage        = 1;
   boxHeadBackPercentage         = 0;
   boxHeadFrontPercentage        = 1;

   

 
   // Controls over slope of runnable/jumpable surfaces
   runSurfaceAngle  = 70;
   jumpSurfaceAngle = 80;

   minJumpSpeed = 20;
   maxJumpSpeed = 30;

   horizMaxSpeed = 68;
   horizResistSpeed = 33;
   horizResistFactor = 0.35;

   upMaxSpeed = 80;
   upResistSpeed = 25;
   upResistFactor = 0.3;
   
  
   
   observeParameters = "0.5 4.5 4.5";

 
};

Then make sure to add functions for the body

function MimickBody::onReachDestination(%this,%obj)
{
   // Moves to the next node on the path.
   // Override for all player. Normally we'd override this for only
   // a specific player datablock or class of players.
   if (%obj.path !$= "") {
      if (%obj.currentNode == %obj.targetNode)
         %this.onEndOfPath(%obj,%obj.path);
      else
         %obj.moveToNextNode();
   }
}

function MimickBody::onEndOfPath(%this,%obj,%path)
{
   %obj.nextTask();
}

function MimickBody::onEndSequence(%this,%obj,%slot)
{
   echo("Sequence Done!");
   %obj.stopThread(%slot);
   %obj.nextTask();
}

Just replace Mimick with flagpole and you have your answer.
#11
04/12/2005 (8:55 am)
Wow!, Thanks a ton @Dreamer, I finally got the animation running. I had to put the "eye" node in the .dts file to make it work. Thanks again.

Also, do you know how the model decides which direction to face; I am getting this problem that the model is running in the oppesite direction i.e. if you map to the AIPlayer in FPS demo the "kork" is running backwards.

Edited: grammer
#12
04/12/2005 (9:09 am)
Only time I've ever had a problem like that is when my eye node was reversed on the x,y axis removing the transform and pointing the node the proper direction solved it for me. I make all my models in blender and so this is kinda trivial to do, but I have no clue how to do it in other modeling apps.
#13
04/12/2005 (12:07 pm)
Wow this is a big thread already

i didnt read the whole thing but i made a fake boat follow a path by mounting it on a pathcamera thing (camera on a path)

the engine has nice pathed cameras that you can specify its rotation and everything but by default you cant mount anything on them

i think i added a function or two so that the class can return a mountpoint:

void PathCamera::getMountTransform(U32 mountPoint,MatrixF* mat)
{
*mat = getRenderTransform();
}

void PathCamera::getRenderMountTransform(U32 mountPoint,MatrixF* mat)
{
*mat = getRenderTransform();
}


then you should be able to mount on them
#14
04/13/2005 (5:54 am)
Thanks @Jerald; this sounds interesting I will try this.

Thanks again @Dreamer; got the animation working correctly; it was the eye node pointing in the wrong direction. Will require one more help! after I am able to run the animation for new DTS object, the earler animation of "Kork" AIPlayer is also replaced by this new DTS object, which I didn't wanted.
#15
04/14/2005 (2:48 am)
@Dreamer; solved the problem. I was using the AIPlayer:: callback (AIPlayer static function)functions as it is for my DTS object so it was taking the same shapeFile for both the AIPlayer object.

I changed all the functions that were configured for AIPlayer:: to my new className, which I had specified in the datablock thay you had suggested.

thanks again for the support!
#16
04/14/2005 (2:53 am)
I don't see why you aren't using the pathed shape resource....
#17
04/14/2005 (3:53 am)
Thanks @Josh; didn't know about that resource thanks for pointing out. I haven't gone through the resource completely but I wanted DTS objects to
- have some amount of AI to run on the terrain
- run the sequence -DSQ file

does the above resource be able to implement this? I didn't find the information by reading through the overview.