Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. Vector3 mousePos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
  2. Vector3 differance = gunArm.transform.position - mousePos;
  3. float gunAngle = Mathf.Atan2 (differance.y, differance.x) * Mathf.Rad2Deg;
  4. //You can edit the float by which gunangle is subracted encase UP or Right isn't always the front of your weapon
  5. gunArm.transform.rotation = Quaternion.Euler (0, 0, gunAngle - 90);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement