Snapping two objects together?
by User · in Torque 3D Professional · 01/13/2010 (8:44 pm) · 3 replies
Hey All,
Had a new concept for a game, and I was planning to put in a track editor. (It's a racing game) So i was wondering if there is any was to code or set a prefrence to tell an object to snap to another when spawned? In Example:
I have a straight peice and a start peice. I measured the and the peices are the exact same width, but I want them to snap together in my track editor. So i set a start peice, and when i spawn a straight peice it will automatcally allign with the default peice and join them together.
Is there any way to predefine or can someone get me a code to accomplish this? If im not being clear enough i can create some graphics to explain.
Thanks,
Matt
Had a new concept for a game, and I was planning to put in a track editor. (It's a racing game) So i was wondering if there is any was to code or set a prefrence to tell an object to snap to another when spawned? In Example:
I have a straight peice and a start peice. I measured the and the peices are the exact same width, but I want them to snap together in my track editor. So i set a start peice, and when i spawn a straight peice it will automatcally allign with the default peice and join them together.
Is there any way to predefine or can someone get me a code to accomplish this? If im not being clear enough i can create some graphics to explain.
Thanks,
Matt
About the author
#2
Thanks for your reply,
Matt
01/14/2010 (10:47 am)
I'm using simple .DAE files made in sketchup. But if I opened it up in a text editor, is there and special way I should set it up? I'm not a master of C++, but if you can get me a code I can put it in there.Thanks for your reply,
Matt
#3
You create your mountPoint and mountX nodes in your 3D modeler, and you use the TorqueScript function
The syntax is misleading for me. here is an example I used :
It will attach the %light object to NBObject so that the node called 'mountPoint' in %light will follow the node called 'mount1' in NBObject.
Nicolas Buquet
www.buquet-net.com/cv/
01/15/2010 (5:28 am)
It has nothing to do with C++.You create your mountPoint and mountX nodes in your 3D modeler, and you use the TorqueScript function
ConsoleMethod( SceneObject, mountObject, bool, 4, 4, "( SceneObject object, int slot )"
"Mount ourselves on an object in the specified slot.")The syntax is misleading for me. here is an example I used :
NBObj.mountObject( %light, 1)
It will attach the %light object to NBObject so that the node called 'mountPoint' in %light will follow the node called 'mount1' in NBObject.
Nicolas Buquet
www.buquet-net.com/cv/
Torque 3D Owner Nicolas Buquet
Look for "mountObject" command, and 'mountPoint', and 'mount0-9' node in your 3D model.
You can then mount an object (or attach) to another, the mountPoint of the first being at the same place as the mountX you choose to attach it to.
The attached object follow the parent object, and if the mountX on which it is attached is animated, the attached object will move with the node animation.
I hope I understand your question and that my answer will help you.
Nicolas Buquet
www.buquet-net.com/cv/