Question by
csMalthius · Dec 16, 2019 at 06:01 PM ·
c#movementfirst-person-controller
Why isn't this code dampining the x-axis of the player movement?
I have these three functions in my code. The goal is to make it so that based on how zoomed in one is, the camera moves less per mouse movement. It seems to work for the vertical movement, but nothing I have done has any effect on the horizontal movement. Can someone please give me a pointer as to what I'm doing wrong? ClampCamera() is called on Update and ZoomData just contains three floats.
Thanks!
public void ClampCamera()
{
var zoomLevel = _owner.CurrentZoomLevel;
ProcessX(zoomLevel);
ProcessY(zoomLevel);
_camTransform.localRotation = Quaternion.Euler(-_yRotCounter, _xRotCounter, 0);
//_camTransform.localEulerAngles = new Vector3(-_yRotCounter, _xRotCounter, 0);
}
private void ProcessY(ZoomData zoomLevel)
{
//Get Y value and limit it
_yRotCounter += Input.GetAxis("Mouse Y") * zoomLevel.TiltSpeed;
_yRotCounter = Mathf.Clamp(_yRotCounter, _owner.minDeclination, _owner.maxDeclination);
}
private void ProcessX(ZoomData zoomLevel)
{
//Get X value and limit it
_xRotCounter += Input.GetAxis("Mouse X") * zoomLevel.PanSpeed;
}
Comment
Your answer
Follow this Question
Related Questions
Setting another script's property from code doesn't actually set the property 1 Answer
Smooth Rotation on WASD keys pressed? 1 Answer
need help with jumping script 1 Answer
How to move model on x axis in increments of 1? Starting from zero at a range of -2 to 2. 2 Answers
Input.GetAxisRaw always returns -0.6 1 Answer