Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Update()
- {
- Vector3 moveDirection = gameObject.transform.position - _origPos;
- if (moveDirection != Vector3.zero)
- {
- float angle = Mathf.Atan2(moveDirection.y, moveDirection.x) * Mathf.Rad2Deg;
- transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement