Guest User

Untitled

a guest
Aug 22nd, 2019
83
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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);
RAW Paste Data