How would tell a spawn clone to use a path?
by Nicolai Dutka · in Torque Game Builder · 03/28/2008 (2:54 pm) · 8 replies
I've got a template creature and 5 spawn points. I want to be able to tell SOME of the cloned spawns to use 1 of 4 paths I have laid out already. Other clones will not use the paths. How would I do this?
#2
I updated my behavior file and now in the editor, I can add a path to my spawn object and I know it works because the drop list shows all 4 of my paths in it and nothing else.
When I run a *.dump on the spawner object, I notice in the report that "patrol path" IS in the list.
When I try to echo it out:
echo(spawn1.patrolpath)
I get nothing but a blank line.
The objects are spawning, but not moving at all. I DID change one part of the line you showed me:
TO:
I verified my path has 8 nodes, 0-7.
I tried to attach objects to the path via console and the line you gave me but it isn't working...
03/29/2008 (10:53 am)
Looks really good, but isn't working for me.I updated my behavior file and now in the editor, I can add a path to my spawn object and I know it works because the drop list shows all 4 of my paths in it and nothing else.
When I run a *.dump on the spawner object, I notice in the report that "patrol path" IS in the list.
When I try to echo it out:
echo(spawn1.patrolpath)
I get nothing but a blank line.
The objects are spawning, but not moving at all. I DID change one part of the line you showed me:
%this.owner.patrolPath.attachObject(%clone, 10, 0.0, [start node], [start node],"WRAP", -1, true);
TO:
%this.owner.patrolPath.attachObject(%clone, 10, 0.0, 0, 7,"WRAP", -1, false);
I verified my path has 8 nodes, 0-7.
I tried to attach objects to the path via console and the line you gave me but it isn't working...
#3
echo(spawn1.object); -Nothing
echo(spawn1.patrolPath); -Nothing
echo(spawn1.count); -Nothing
Yet all 3 of those show up in the "tagged fields" when I run "spawn1.dump".... What the heck?
03/29/2008 (10:59 am)
Weirdness:echo(spawn1.object); -Nothing
echo(spawn1.patrolPath); -Nothing
echo(spawn1.count); -Nothing
Yet all 3 of those show up in the "tagged fields" when I run "spawn1.dump".... What the heck?
#4
Therefore, the following is telling me "object not found" when I run it:
03/29/2008 (11:04 am)
So, it works for "member fields" but not "tagged fields"...Therefore, the following is telling me "object not found" when I run it:
%this.owner.patrolPath.attachObject(%clone, 10, 0.0, 0, 7,"WRAP", -1, false);
#5
From:
To:
03/29/2008 (11:09 am)
Ok, I got it working. Had to remove "owner" from those lines:From:
%this.owner.patrolPath.attachObject(%clone, 10, 0.0, 0, 7,"WRAP", -1, false);
To:
%this.patrolPath.attachObject(%clone, 10, 0.0, 0, 7,"WRAP", -1, false);
#6
I can attach an object to a path and it will follow the path.
I can mount a path to an object and it will follow that object.
If I attempt to attach an object to a path that is mounted to another object, the game crashes.
Any ideas?
03/29/2008 (2:38 pm)
New problem, crashing the game:I can attach an object to a path and it will follow the path.
I can mount a path to an object and it will follow that object.
If I attempt to attach an object to a path that is mounted to another object, the game crashes.
Any ideas?
#7
Here is my code:
03/29/2008 (2:49 pm)
Oh SORRY! Forgot to mention, I am working with clones!Here is my code:
%path = shieldPath.cloneWithBehaviors();
%shield = shieldObject.cloneWithBehaviors();
%path.attachObject(%shield,60,0.0,0,1,"WRAP",-1,true);
%path.mount(player1);
$p1shield=1;
#8
The clone function is bugged - it doesn't copy the path nodes. I made a quick work around:
Let me know how this works for you.
03/30/2008 (7:18 am)
King, The clone function is bugged - it doesn't copy the path nodes. I made a quick work around:
function SpawnTestBehavior::spawn(%this)
{
if (!isObject(%this.object))
return;
%clone = %this.object.cloneWithBehaviors();
if (isObject(%this.path))
{
%path = %this.path.cloneWithBehaviors();
for (%i = 0; %i < %this.path.getNodeCount(); %i++)
%path.addnode(%this.path.getnode(%i));
%NodeMax = %path.getNodeCount() - 1;
%path.attachObject(%clone, 10, 0.0, 0, %NodeMax,"WRAP", -1, true);
%path.mount(%this.owner);
}
}Let me know how this works for you.
Torque 3D Owner Patrick Shaw
There's are many ways to do this. IMHO, the easiest way is to add an "object" field to your spawn behavior that displays only the paths in your scene.
After you spawn the object, use the following:
if(isObject(%this.owner.patrolPath)) %this.owner.patrolPath.attachObject(%clone, 10, 0.0, [start node], [start node],"WRAP", -1, true);You'll have to either manually insert the start and end node parameters for your path or enter them procedurally.
Thus, if you don't select an object in the behavior field, the spawned object will not be attached to a path.