I'm trying to set up a game with portals in it. I've been struggling for a while now to rotate the Player. I've tried Quat.Slerp, Quat.AngleAxis, and Quat.Euler. But through rigorous testing I discovered that the MouseLook function in my FPS Controller script is the reason the Player isn't rotating. The player is being rotated, but half a frame later, the MouseLook script resets the Player's rotation.
How can I rotate the player without letting the MouseLook function of my FPS Controller script get in the way?
void MouseLook()
{ mouseX = Input.GetAxisRaw("Mouse X") * sensX * Time.deltaTime;
mouseY = Input.GetAxisRaw("Mouse Y") * sensY * Time.deltaTime;
yRot += mouseX; xRot -= mouseY;
xRot = Mathf.Clamp(xRot, -50f, 50f);
transform.rotation = Quaternion.Euler(xRot, yRot, 0);
}
xRot
andyRot
public, I'd be able to change their values from my other script? Better yet, I think I'll try performing the rotation within my FPS controller script...brb (EDIT) K im back. Its not gonna work coz im doing math from a separate script. Unless I can access one script from another??? – Jason Burley Oct 17 '22 at 17:38xRot
andyRot
public and static did the trick! Omfg works so good. – Jason Burley Oct 18 '22 at 04:38