- Home /

# How does rotation.LookAt work?

As I am currently dealing with a problem Not In Unity I have determined that if I was in Unity I could solve the problem trivially in three lines with LookAt()

Sadly I'm not in Unity.

How does this function work?

I'm working with raw position data (x,y,z) so rotations are calculatable, but only necessary for a single virtualized object (as vector from an origin to a target). Once I have that rotation information performing a virtualized localPosition offset would be easy.

Problem is, I can't figure out how to calculate the vector.

Does anyone know how the function actually works?

**Answer** by Seth-Bergman
·
Sep 13, 2013 at 12:09 AM

to calculate a vector from one position towards another, just subtract one from the other..

example: position 2 (0,6,10) - position 1 (0,3,3) == direction(0,3,7)

so, starting from position 1, the direction to pos 2 is (0,3,7)... does that answer your question? you can find plenty of examples online...

Did not answer question.

I am not interested in knowing the vector from A to B (I can calculate that in my sleep), I need to offset B by the local coordinate grid created by aligning a Cartesian coordinate system with the vector from A to B such that I can create lines originating from B in a spiderweb pattern on the surface defined by the normal BA.

### Your answer

### Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.