- Home /
Location in relation to other objects rotation
Hi,
So I have a person (A). Now I want to set the location of a second person (B) that should be standing in a certain position in relation to A. Like this:
(^ means a person that's looking in that direction)
---^---
-----^-
So the second person is standing behind the other person at a given angle (135 degrees) at a given distance (x). His rotation is the same. What I want to find is the location of person B. I can't for the life of me figure out how to calculate this from A's quaternion (or what keywords to google for ^.^), even though I realise it's relatively simple o.O.
Thanks!
In this in Unity..? Why can't you access the position of person B?
I want to set his position. I don't know how to calculate what coordinates that should be though.
edited the question to make that more clear :)
Answer by amirabiri · May 22, 2012 at 08:48 AM
OK now that I understand the question, the answer is that you should look at the methods on the Transform class such as TransformDirection, TransformPoint. The methods of the Transform class cover all cases of translating between local and world coordinates, which is essentially what you are trying to do here.
As a rule of thumb, unless you absolutely have too it's better not to go head-to-head with the rotation Quaternion. As you just discovered, she can bite.
Ah, didn't realise Unity took so much work from me :). (New to it ;)). Thanks!