- Home /
Question by
Nanako · Jul 11, 2015 at 07:44 PM ·
rotationquaternionoffset
Turning a vector into a local offset? Math help
Ok, i have an object, A And i have a point in space, B (its a vector3)
What i want to find, is B's local offset from the location of A, expressed in A's local axes. (A is at a random and arbitrary rotation)
I've gotten as far as B = B - A.transform.position; This gives me an offset in world axes, which is nice but not useful. How do i convert that into A's local coordinate system?
Comment
Best Answer
Answer by maccabbe · Jul 11, 2015 at 08:04 PM
Answer by SteelBlade · Jul 12, 2015 at 09:33 AM
The Transform component provides a lot of great conversion tools, such as:
transform.InverseTransformDirection(your calculated offset);
It converts world directions to the local directions of the transform it is called on.