- Home /
Question by
simonpeterkovacs · Jan 02, 2020 at 12:41 PM ·
relative rotation
How to add camera rotation to character rotation such that it rolls over at pi?
So I have this code in update:
if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
{
animator.SetBool("walking", true);
direction = Mathf.Atan2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));//add camera rotation here somewhow
transform.Translate(Vector3.forward * Time.deltaTime * speed);
}
else
{
animator.SetBool("walking", false);
}
transform.rotation = Quaternion.Euler(0, Mathf.Rad2Deg * direction, 0);
print(cam.transform.rotation.y);
I have no idea how to make it so that the "forward" direction is away from the camera as opposed to posX for example.
Comment