- Home /

# Constructing a Vector in 2-space from an angle for camera panning

Hello all,

I am trying to pan an overhead camera around a map. To realize this goal, I am translating the camera's position based on the Mouse X and Mouse Y Input Axes and a "Pan Speed."

For moving right/left, I can simply use Vector3.Right and Space.Local, and all is well. However, since the Camera is tilted down, I cannot use Vector3.Forward and Space.Local, as that would have more of a "zooming" effect (I'd be getting closer/further to the ground, not panning).

I need to figure out the Vector by which I should translate, based on the Y-value from my Euler angles.

I thought this was a simple math problem, and used the formula U = cos(x), sin(x) to try to get the appropriate Unit Vector.

I tried to accomplish this via the following code snippet:

```
Vector3 forwardAngles = new Vector3(Mathf.Cos(transform.localEulerAngles.y * Mathf.Deg2Rad), 0, Mathf.Sin(transform.localEulerAngles.y * Mathf.Deg2Rad));
forwardAngles.Normalize();
transform.Translate(forwardAngles * Input.GetAxis("Mouse Y") * panSpeed * -1 , Space.World);
```

But somehow I am calculating the Vector incorrectly. Please advise.

Love Unity!

**Answer** by tigertrussell
·
Jun 14, 2013 at 12:14 AM

I ended up creating a parent game object which I could use Vector3.forward and Vector3.right on. This is a much easier solution.

### 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.