Game Development Community

How to attach an object to a path?

by Jordi Castella · in iTorque 2D · 03/27/2011 (8:17 am) · 6 replies

Hi everybody!

i'm trying to attach an object to a path and i can't do it.

i create a path on TGB, then i try to attach the object mounting it to a node, seem to be impossible.

is path working properly on iTorque, or isn't implemented yet?

thx in advance.

#1
03/27/2011 (8:22 am)
It's working fine but it can be fiddly, I don't use them too often so keep at it and hopefully someone else will reply with some useful tips.
#2
03/27/2011 (10:20 am)
@Jordi - I don't have any problems mounting. I'm creating a tutorial right now, but here are my steps

1. Add Path Object
2. Create some nodes
3. Add a sprite to the scene
4. Click the mount object to other object button
5. Hover the mouse pointer directly over the node
6. Left click

That works for me each time. If I move the path object around the scene my sprite is attached to it. Are you saying this last part is not working?
#3
03/27/2011 (10:52 am)
Don't know why ... but now it works lol.

Question is .... Start node, End node, Speed, Move, Orient, loops. Follow mode, etc.... How i code all this stuff?
I know in torque 2d Path window refreshes with all this when an object is attached. Where i need to go in iTorque to do the same?

Thx Michael ... u r like god .... u sleep? ;)
#4
03/27/2011 (11:11 am)
@Jordi - Ok, so there are some weird things going on with the Path object that I did not notice before. In the short term, you can get some more information using the TGB Documentation. I am working on the new guide which will be a lot cleaner and more instructional. The pathing properties are on the object you are mounting to the path, not the path itself.

Quote:Thx Michael ... u r like god .... u sleep? ;)
Happy to help. Not god, just trying to represent Torque the best I can. I get plenty of sleep. Our CEO is an optimization expert, so he applied that knowledge to our work habits so we do not have to work unreasonable hours. =)
#5
03/27/2011 (11:29 am)
good to know

i have read some bad posts in the past about support here at Torque. This is the reason i started with Unity3d one year ago. Now i can say, i don't know if that was true, but i'm impressed with Torque support since i purchased iTorque 2D.

i'm happy to be here with all of you.

Thx to you and all the pple who brings help to noobs like me. If anybody need some help from me about graphic design i'll try the best.
#6
03/28/2011 (3:04 am)
Hi there, i managed to attach an object to a path with this CODE:


function Enemy::onLevelLoaded(%this, %scenegraph)
{
%this.schedule(3000, "newPath");
}

function Enemy::newPath(%this)
{
%newPath = new t2dPath() { scenegraph = %this.scenegraph; };

%newPath.addNode("0 0", 0);
%newPath.addNode("-100 0", 1);
%newPath.addNode("-200 -200", 2);
%newPath.addNode("0 -100", 3);

%newPath.setPathType("CATMULL");

%newPath.attachObject(%this, 50.0, 1, 2, 1, "WRAP", 3, false);


}

Problem is Enemy is a class and all the enemies attach once to the same node. Any advice on how to handle attaching to different nodes?

Thanks.