Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation: Collision Location

Gigs Taggart
The Invisible Hand
Join date: 12 Feb 2006
Posts: 406
03-25-2006 23:12
I'm trying to detect where a collision happened on the face of a prim. The face is flat ( a nearly 2D prim) , and I want to get sort of 2D cartesian coodinates with the center of the face as the origin.

I got it working when the prim is axis aligned, but rotating it breaks it.

I rotated both positions by llGetRot, and it almost works, except when it's rotated 90 degrees about the z-axis, the output is flipped, i.e. collisions in 2D cartesian quadrant one come out -,+ instead of +,+.

So I'd like to make the coodinates output completely independant of rotation. They would be the cartesian location on the face where the collision happened, no matter what.

Here's the code in collision_start:
CODE

rotation rot=llGetRot();
vector hitpos=(llDetectedPos(0)*rot)-(llGetPos()*rot);
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
03-25-2006 23:34
Try:
CODE
vector hitpos = (llDetectedPos(0) - llGetPos()) / rot
_____________________
---
Gigs Taggart
The Invisible Hand
Join date: 12 Feb 2006
Posts: 406
Thanks!
03-26-2006 00:02
Works perfectly.