- Home /
Question by
Waykzen · Jan 09, 2020 at 12:52 PM ·
camerarotationfps controller
Rotate smoothly to place?
I am making a game where when you are jumping yan can make a salton to shoot down, the problem is when i have my camera down and i am landing my camera clip downward. can you help me plz??
there is my code :
public float mouseSensitivity = 100f;
public Transform playerBody;
float xRotation = 0f;
public bool isGrounded;
public Transform GroundCheck;
public float groundDistance = 0.4f;
public LayerMask groundMask;
public Transform GroundCheckBig;
public bool isLanding;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
isGrounded = Physics.CheckSphere(GroundCheck.position, groundDistance, groundMask);
isLanding = Physics.CheckSphere(GroundCheckBig.position, groundDistance, groundMask);
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= mouseY;
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
}
Thank you.
Comment