SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 75 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top