Question by
daniel-few · Nov 17, 2020 at 03:08 PM ·
camera-movement
Why does my mouse sensitive change from editor to build?,Why does my mouse sensitivity change from editor to build?
I've followed some tutorials to setup a camera controller in Unity w/ Mirror. When I play in editor, it works fine. However the mouse sensitive is much, much, much more sensitive in build. It might have something to do with Razer Synapse, but I can't pointpoint it. Can anyone help?
using Mirror;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerCameraController : NetworkBehaviour
{
[SerializeField] private Camera playerCamera;
[SerializeField] private float mouseSensitivty = 10f;
private Controls controls;
private Controls Controls {
get {
if(controls != null) { return controls; }
return controls = new Controls();
}
}
private float xRotation = 0f;
public override void OnStartAuthority()
{
Cursor.lockState = CursorLockMode.Locked;
playerCamera.enabled = true;
Controls.Player.Look.performed += ctx => Look(ctx.ReadValue<Vector2>());
enabled = true;
}
[Client]
private void OnEnable() => Controls.Enable();
[Client]
private void onDisable() => Controls.Disable();
private void Look(Vector2 lookAxis)
{
float mouseX = lookAxis.x * mouseSensitivty * Time.deltaTime;
float mouseY = lookAxis.y * mouseSensitivty * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
playerCamera.transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
transform.Rotate(Vector3.up * mouseX);
}
}
I have also tried removing Time.deltaTime from these two lines
float mouseX = lookAxis.x * mouseSensitivty * Time.deltaTime;
float mouseY = lookAxis.y * mouseSensitivty * Time.deltaTime;
As I read this wasn't needed for mouse movement? However in build it's still noticeably faster.
Comment
Your answer
Follow this Question
Related Questions
My camera rotate but my player dont. How Ive to do so? 1 Answer
Top Down Game - Camera Follow Player and General Scripting Question 0 Answers
Another Smooth Camera Follow problem 1 Answer
camera zoom/moveing and object position 0 Answers
Unity 2D how to create pocky and rocky 2 camera in c#??? 2 Answers