tX = finger.ScreenDelta.x;
tY = finger.ScreenDelta.y;
primaryWeapon.transform.Rotate(new Vector3(-tY * primaryWeaponAgility * PlayerPrefs.GetFloat(“ScopeSens”) * Time.deltaTime, tX * primaryWeaponAgility * PlayerPrefs.GetFloat(“ScopeSens”) * Time.deltaTime, 0));
primaryRotationX=Mathf.Clamp(primaryWeapon.transform.localEulerAngle.x, -6f, 6f);
primaryRotationY=Mathf.Clamp(primaryWeapon.transform.localEulerAngles.y, -36f, 36f);
primaryWeapon.transform.localRotation=Quaternion.Euler(primaryRotationX, primaryRotationY, 0f);
I’m using this script to rotate my weapon object which a child of the player object
the rotation happens every frame based on the touch input
the script works fine except the part where its supposed to clamp the rotation of the weapon to stop it from facing the player.
Now this part only works for the right and top rotation and not for bottom and left rotation
Please suggest any possible solution to this problem as i’m unable to solve it by my self
any suggestions and ideas would be really appreciated
Thanks