Object Orientation on Path
by Tom Lenz · in Torque Game Builder · 03/18/2008 (2:05 pm) · 9 replies
I have created a path and sent some bad guys down the path.
Only problem is that their head is always forward.
I'm probably not explaining this well, but I just want the sprites
to keep their rotation, instead of rotation along the path.
I have seen the check box in the gui but was wondering if there
was a way to do the same thing in code?
Only problem is that their head is always forward.
I'm probably not explaining this well, but I just want the sprites
to keep their rotation, instead of rotation along the path.
I have seen the check box in the gui but was wondering if there
was a way to do the same thing in code?
#2
03/19/2008 (8:41 am)
I cant seem to find anything on it. Searching the forums and looking through references and tutorials.
#3
The object-path related commands are in the reference documentation under "t2dpath". The command that you are looking for is:
%path.setOrient(%badGuy, false);
03/19/2008 (9:34 am)
Tom, The object-path related commands are in the reference documentation under "t2dpath". The command that you are looking for is:
%path.setOrient(%badGuy, false);
#4
Make code looks as follows.
03/19/2008 (11:55 am)
So I added the code and it still doesnt want to work.Make code looks as follows.
%delay = 1200;
for(%i = 0; %i < 20; %i++)
{
%spawnDelay = ((%i+1) * %delay);
path.setOrient($attackers.getObject(%i), false);
path.schedule(%spawnDelay, attachObject, $attackers.getObject(%i),5,0,0,0,0,0,0);
}
#5
Try:
03/19/2008 (3:17 pm)
I think it is beacuse you are FIRST using setOrient function, and THEN you attach them into path. Try:
%delay = 1200;
for(%i = 0; %i < 20; %i++)
{
%spawnDelay = ((%i+1) * %delay);
path.schedule(%spawnDelay, attachObject, $attackers.getObject(%i),5,0,0,0,0,0,0);
path.setOrient($attackers.getObject(%i), false);
}
#6
attacker0 is the name of the sprite
any other ideas would be great.
03/19/2008 (3:44 pm)
Yep still not working... I even tried it like this%delay = 1200;
for(%i = 0; %i < 20; %i++)
{
%spawnDelay = ((%i+1) * %delay);
path.schedule(%spawnDelay, attachObject, $attackers.getObject(%i),5,0,0,0,0,0,0);
path.setOrient(attacker0, false);
path.setOrient(attacker1, false);
path.setOrient(attacker2, false);
}attacker0 is the name of the sprite
any other ideas would be great.
#7
"attacker0" is the name of the object, not the sprite animation in library? (i suppose it is the name of the object)
Try using: echo( path.getOrient(attacker0) ); to see what will be dumped into console.
Or even: if( isobject(...) ) { ... }
Echo-ing can give you some answers when you are not sure what is going on in the code.
i really must try this on my own since i havent worked with paths before.
I suppose you are trying to make a shooter game, right? ;)
03/19/2008 (4:59 pm)
Is the object actually attached to the path after you apply this code?"attacker0" is the name of the object, not the sprite animation in library? (i suppose it is the name of the object)
Try using: echo( path.getOrient(attacker0) ); to see what will be dumped into console.
Or even: if( isobject(...) ) { ... }
Echo-ing can give you some answers when you are not sure what is going on in the code.
i really must try this on my own since i havent worked with paths before.
I suppose you are trying to make a shooter game, right? ;)
#8
All of the comments helped me figure it out myself.
Since I was scheduling the attaching of the objects, I figured I needed to do
the same with the setOrient as well. Otherwise I was trying to do it before
the guys were actually on the path. Milan this is actually for a tower defense
game that I am working on for school/portfolio.
Here is how the code ended up.
Thanks
03/19/2008 (9:51 pm)
Thanks everyone for trying to help.All of the comments helped me figure it out myself.
Since I was scheduling the attaching of the objects, I figured I needed to do
the same with the setOrient as well. Otherwise I was trying to do it before
the guys were actually on the path. Milan this is actually for a tower defense
game that I am working on for school/portfolio.
Here is how the code ended up.
%delay = 1200;
for(%i = 0; %i < 20; %i++)
{
%spawnDelay = ((%i+1) * %delay);
path.schedule(%spawnDelay, attachObject, $attackers.getObject(%i),5,0,0,0,0,0,0);
path.schedule(%spawnDelay, setOrient, $attackers.getObject(%i), false);
}Thanks
#9
Ok, glad i helped. Happy toquing ^_^
03/20/2008 (12:03 am)
Yea, schedule... I wasnt thinking. But i supposed that the problem might be that you must first attach object, THEN to tell him what to do with that path.Ok, glad i helped. Happy toquing ^_^
Milan Rancic
Try searching the TGB reference for some function that have "orientation" or "path" in its name. Maybe you'll find something that you nead.
If you still having issue with this, ill try to help you. But i can only do it later. ;)