a guest Aug 22nd, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- Vector3 mousePos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
- Vector3 differance = gunArm.transform.position - mousePos;
- float gunAngle = Mathf.Atan2 (differance.y, differance.x) * Mathf.Rad2Deg;
- //You can edit the float by which gunangle is subracted encase UP or Right isn't always the front of your weapon
- gunArm.transform.rotation = Quaternion.Euler (0, 0, gunAngle - 90);
RAW Paste Data