OnCollosion Normal vector
by Phillip O'Shea · in Torque Game Builder · 07/27/2007 (5:09 am) · 2 replies
Hello,
I need to know how the %normal variable in the onCollision function is calculated. I don't have TGB Pro, otherwise I'd be able to find out myself.
Essentially, I have two collision points (from the collision polygon, so they are in local position terms) and I want to calculate their normal vectors, but I need to do it before the onCollision function is called.
Thanks guys,
Phil
I need to know how the %normal variable in the onCollision function is calculated. I don't have TGB Pro, otherwise I'd be able to find out myself.
Essentially, I have two collision points (from the collision polygon, so they are in local position terms) and I want to calculate their normal vectors, but I need to do it before the onCollision function is called.
Thanks guys,
Phil
About the author
Head of Violent Tulip, a small independent software development company working in Wollongong, Australia. Go to http://www.violent-tulip.com/ to see our latest offerings.
#2
I'm not 100% sure that I understood all of that. Do you think you could give me an example?
Edit: I found out what I needed, it was pretty simple really.
For those interested, I had two points A = (a1, a2) and B = (b1, b2). I found the line AB by taking A from B and then scaling A to keep it uniform with B. Then divide through by the hypotenuse!
Thanks,
Phil
07/29/2007 (3:00 am)
Hi Marc,I'm not 100% sure that I understood all of that. Do you think you could give me an example?
Edit: I found out what I needed, it was pretty simple really.
For those interested, I had two points A = (a1, a2) and B = (b1, b2). I found the line AB by taking A from B and then scaling A to keep it uniform with B. Then divide through by the hypotenuse!
Thanks,
Phil
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
*and if you have the polygon, its actually very simple. Just use the direction from one of the points to the next of the 2 points that form the connection on which the collision point is laying, then exchange the components and negate one of the two. which one you need to negate, depends on which side is the "outside" of the polygon and can easily be calculated using a 3rd point on the collision polygon.*