- Home /

# Deriving and angle from two points

So I need to derive an angle from two points in 2D space.

I have tried this:

```
Vector2.Angle(p1,p2);
```

But it doesn't actually give me an angle, it gives a directional vector I think. There must be a simple answer right? my search has turned up allot of confusing information that doesn't seem to directly answer my problem. Perhaps the question is how you'd convert a directional vector to an angle.

Regardless, I'm stuck. Any insight would be appreciated.

**Answer** by Poyer
·
Aug 29, 2011 at 03:10 AM

Alright, this was pretty simple...

to get the angle all i needed was this line:

```
var angle : float = Mathf.Atan2(p2.y-p1.y, p2.x-p1.x)*180 / Mathf.PI;
```

A bit nicer with Rad2Deg:

```
var angle : float = $$anonymous$$athf.Atan2(p2.y-p1.y, p2.x-p1.x) * $$anonymous$$athf.Rad2Deg;
```

I tried to get lookat to work for a solid hour! You solution turned out to work as perfectly Thanks!

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.