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.
directionX
/Z
values, so you should show us that part, along with a detailed description of the symptoms you need to solve. – DMGregory Oct 19 '19 at 12:33