Hi, iam new to Unity and tried making a FPS game.
It worked well but now my Camera isn´t smooth anymore.
I dont know why this happend and didnt changed anything.
Does anybody know how to fix this problem?
sociablemisguidedafricanwildcat
Hi, iam new to Unity and tried making a FPS game.
It worked well but now my Camera isn´t smooth anymore.
I dont know why this happend and didnt changed anything.
Does anybody know how to fix this problem?
sociablemisguidedafricanwildcat
Looks like an issue with your rotation script. Show your code, but I’d guess you did something improper like this:
Input.GetAxisRaw("Mouse X") * Time.deltaTime
Do not multiply Time.deltaTime into your mouse input. It is wrong and will cause issues like you are seeing.
Indeed, could be that one, as that time is variable depending on the game load, possibly that is why see a difference depending on how the game changed since it worked better
Removing *t ime.deltaTime even made the problem bigger.
Heres my Code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseLook : MonoBehaviour
{
public float mouseSensitivity = 100f;
public Transform playerBody;
float xRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void FixedUpdate()
{
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity;// * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity;// * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
playerBody.Rotate(Vector3.up * mouseX);
}
}
formalobedientdavidstiger
Now your mouse sensitivity just seems way too high. Reduce it to something reasonable, like 1.
OK its works now thank you.