Ok this problem is hard to explain, but ill do my best. First here is the code for my playerController:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
[SerializeField] private GameObject _camera;
private Vector3 _playerVelocity;
private float _playerRotation = 0;
private Ray _ray;
private RaycastHit _hit;
private int _grounded = 0;
private void Update()
{
_playerVelocity = new Vector3(0, 0, 0);
if (Input.GetKey("w"))
{
_playerVelocity += new Vector3(0, 0, 1);
}
if (Input.GetKey("a"))
{
_playerVelocity += new Vector3(-1, 0, 0);
}
if (Input.GetKey("s"))
{
_playerVelocity += new Vector3(0, 0, -1);
}
if (Input.GetKey("d"))
{
_playerVelocity += new Vector3(1, 0, 0);
}
if (Input.GetKey("space") && _grounded != 0)
{
_playerVelocity += new Vector3(0, 5, 0);
}
gameObject.transform.Rotate(new Vector3(0, Input.GetAxis("Mouse X") * 3, 0));
_playerRotation = Mathf.Clamp(_playerRotation - Input.GetAxis("Mouse Y") * 3, -90, 80);
_camera.transform.eulerAngles = new Vector3(_playerRotation, gameObject.transform.eulerAngles.y, gameObject.transform.eulerAngles.z);
}
private void FixedUpdate()
{
gameObject.GetComponent<Rigidbody>().AddRelativeForce(_playerVelocity * 20);
_ray = new Ray(gameObject.transform.position, Vector3.down);
if (Physics.Raycast(_ray, out _hit, 1.1f))
{
if (_hit.transform.gameObject.tag == "Ground"){
_grounded = 10;
}
else
{
if (_grounded > 0)
{
_grounded -= 1;
}
}
}
else
{
if (_grounded > 0)
{
_grounded -= 1;
}
}
}
}
The code works absolutely fine normally, i can move, jump, look left right up and down, however when i lower my framerate (i remove my charger) I can no longer rotate horizontally with my mouse.
to be more specific, its not that the horizontal rotation just doesnt work, the camera does rotate in the direction i am trying, and the Mouse X variables are fine (i used print()) but when i look in a direction, some kind of force pulls the camera back to the center, basically undoing my rotation.
if this didnt make too much sense, here is a video, though its hard to demonstrate.