Finding the path marker the player is headed to
by Andy Hawkins · in Torque Game Engine · 07/26/2007 (8:41 am) · 1 replies
How can I address the member 'internalName' in the context of the path Marker defined below.
I want to do something like
Here's my code...
I'm trying to rig the method like this... but I don't know how to call internalName...
I want to do something like
if (currentPath.currentMarker.internalName $= "wait5")
{
// do something
}Here's my code...
new Path(Human1Path) {
canSaveDynamicFields = "1";
isLooping = "1";
new Marker(Marker1) {
canSaveDynamicFields = "1";
internalName = "wait5"; // <- get to this member????
position = "792.084 832.16 -28.8";
rotation = "1 0 0 0";
scale = "1 1 1";
seqNum = "1";
type = "Normal";
msToNext = "1000";
smoothingType = "Spline";
};
...I'm trying to rig the method like this... but I don't know how to call internalName...
function HumanAIPlayer::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 !$= "")
{
// resume normal handling
if (%obj.currentNode == %obj.targetNode)
%this.onEndOfPath(%obj,%obj.path);
else
{
// is there something for the object to do?
// check the internal name where a task may reside
// currently there is waitX or loadX
// waitX is wait X number of seconds
// loadX is grab an object and wait X seconds before moving off
if (%obj.path.internalName $= "wait5") // < -------- this is bit that doesn't work
{
// call wait and schedule to moveToNextNode after wait
AIPlayer::wait(%this,5);
%this.schedule(5 * 1000,"moveToNode",%obj);
}
else
{
%obj.moveToNextNode();
}
}
}
}
Associate Andy Hawkins
DrewFX
Here's how to access the current marker the path is pointed to. What it does is allow you to use the 'internalName' field to give a human, or bot or whatever, extra instructions before it heads off to the next waypoint. In my case I want to give the player the impression the humans are going to a point, picking something up or performing a job, then taking objects with them or moving to something else. So a human could be fixing a bunch of generators, or moving stock from a warehouse to a boat etc.
%node = %obj.path.getObject(%obj.currentNode); if (%node.internalName $= "wait5") { // call wait and schedule to moveToNextNode after wait %this.ailoop2=%this.schedule(5 * 1000,"moveToNode",%obj); } else { if (%node.internalName $= "load5") { // call play load animation and schedule to moveToNextNode after wait // also mount object to human %this.ailoop2=%this.schedule(5 * 1000,"moveToNode",%obj); } else { if (%node.internalName $= "dump5") { // call play dump animation and schedule to moveToNextNode after wait // also unmount object from human %this.ailoop2=%this.schedule(5 * 1000,"moveToNode",%obj); } else { %obj.moveToNextNode(); } } }