Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. void Update()
  2. {
  3. Vector3 moveDirection = gameObject.transform.position - _origPos;
  4. if (moveDirection != Vector3.zero)
  5. {
  6. float angle = Mathf.Atan2(moveDirection.y, moveDirection.x) * Mathf.Rad2Deg;
  7. transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
  8. }
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement