I feel like I’m taking crazy pills here, but I’m attempting to add mouse smoothing to my game. Found a script someone posted to share. Tried to clamp the rotation on the x rotation. And it is just flat out not working at all and I’m kinda going nuts.
if (_cameraT.eulerAngles.x > 90) _cameraT.eulerAngles = new Vector3(90, _cameraT.rotation.y, _cameraT.rotation.z);
if (_cameraT.eulerAngles.x < -90)
{
Debug.Log("Ting");
_cameraT.eulerAngles = new Vector3(-90, _cameraT.rotation.y, _cameraT.rotation.z);
}
}
I am baffled why the log isn’t even firing.
BTW, I do know clamp is a thing but it will not work for this particular script.
Not sure how large you’re letting that list get to, but it will have a “dead” or “laggy” feel to it because you are linearly adding the historical terms up.
At a minimum you should be increasing the importance / weight of the most-recent terms.
This controller:
handles the mouse smoothing at around line 206/207 with a simple Lerp on each axis. The “acc” variables are the accumulating term that the raw inputs are fed into.
Yes, that’s not the “intended” purpose of Lerp, but Lerp has a secondary role as an easy-cheesy low-pass filter, giving high importance to recent inputs and less and less to past accumulated inputs.