Mounting one object to another at the collision point
by Bryan Clarke · in Torque X 2D · 02/16/2010 (6:40 pm) · 3 replies
Hey all, I've searched high and low and I haven't found a concrete answer for what is probably a simple question. I have my player object, and a little guy I've named Sticky Dude. Sticky Dude sits there until the player comes near, and then throws himself with wild abandon towards the player, hoping to catch him in his sticky embrace. Or at least that's what I would like to happen.
So far, I've got the sitting and leaping part down, but I can't mount the Sticky Dude to the player at the point where the two collide. Link points are expressed as local coordinates, and the collision info is in world coordinates. To make matters worse, my player could be rotated any which way at the point of collision, so the link point has to be made taking that into consideration. I did find a reference to "getLocalPoint" in the TGB/Reference, which looks like it would do the job, but it doesn't seem to pop up in C#. Am I missing an import? Do I need to make my own function? How would I do this? Where am I? I'm so confused!
So far, I've got the sitting and leaping part down, but I can't mount the Sticky Dude to the player at the point where the two collide. Link points are expressed as local coordinates, and the collision info is in world coordinates. To make matters worse, my player could be rotated any which way at the point of collision, so the link point has to be made taking that into consideration. I did find a reference to "getLocalPoint" in the TGB/Reference, which looks like it would do the job, but it doesn't seem to pop up in C#. Am I missing an import? Do I need to make my own function? How would I do this? Where am I? I'm so confused!
#2
02/16/2010 (7:51 pm)
I saw that too. Any ideas? I am a math idiot.
#3
It wouldn't be as precise, but if you put a few link points on it might be a reasonable compromise.
02/17/2010 (7:48 pm)
To avoid math - create some link points on the object you want to stick to and then call GetWorldLinkPosition() to work out which one is closest to the collisions point, and mount to that link point.It wouldn't be as precise, but if you put a few link points on it might be a reasonable compromise.
Torque Owner Duncan Colvin