Given a top-down persepective and lets say I know the angle I want to look at, how do I make a gameobject look into that angle? I currently have code like this:

```
if (directionX != 0 && directionZ != 0)
{
transform.rotation = Quaternion.LookRotation(new Vector3(directionX / 2, 0, directionZ / 2));
}
else if (directionX != 0 || directionZ != 0)
{
transform.rotation = Quaternion.LookRotation(new Vector3(directionX, 0, directionZ));
}
```

which allows me to move look into 8-directions. I am now looking to make it so I can look in any angle and I've got the angle using:

```
var angle = Mathf.Atan2(directionZ, directionX) * Mathf.Rad2Deg;
```

but I don't know how to use it to make my object look into that angle.

- Serverfault Help
- Superuser Help
- Ubuntu Help
- Webapps Help
- Webmasters Help
- Programmers Help
- Dba Help
- Drupal Help
- Wordpress Help
- Magento Help
- Joomla Help
- Android Help
- Apple Help
- Game Help
- Gaming Help
- Blender Help
- Ux Help
- Cooking Help
- Photo Help
- Stats Help
- Math Help
- Diy Help
- Gis Help
- Tex Help
- Meta Help
- Electronics Help
- Stackoverflow Help
- Bitcoin Help
- Ethereum Help