Mouse Look clamping problem
i have tried a lot of diferent aproaches and even copied and pasted other people code, but nothing helped so.. i'm sorry if that's a repeated question.
void Look()
{
Vector3 torRotF = Vector3.zero;
Vector3 torRot = Torso.transform.eulerAngles;
torRot.x -= Input.GetAxis("Mouse Y")*mouseMultiplier*Time.deltaTime;
if(torRot.x > 0.0f)
{
torRotF = torRot;
if(torRot.x > 60.0f)
{
torRotF.x = 60.0f;
}
}
else if(torRot.x <= 0.0f)
{
torRotF = torRot;
if(torRot.x < -60.0f)
{
torRot.x = -60.0f;
}
torRotF.x = torRot.x + 360;
Debug.Log("valor inserido no eixo x do torso : " + torRotF.x.ToString());
}
Torso.transform.eulerAngles = torRotF;
}
the thing is, i'm using this code, and when the torso angle is <= 0 ( or between 300 and 360 as i'm trying to input ) it just clamp to 60.
can anyone help me ? i readed a lot of related answers and watched a lot of videos, can't solve this for days now.
That can be a lot of things. I see these problems often. Its not worth my time necessarily to solve this because it might take me 10-20 $$anonymous$$utes, but its definitely solveable, and its an easy problem. If its clamping to 60, its probably getting stuck on line 11, and it becomes an infinite loop of defaulting to the "make 60" part of the code.
Your answer
Follow this Question
Related Questions
Resident Evil 4 Style Aiming Window - Rotational Problem When Aiming 1 Answer
Cant add Torque and Rotation to a rigidbody in the same frame? 2 Answers
Trying to MathF.Clamp y axis rotation results in x equal 270 and y equal max value instantly 1 Answer
Rotating 2D Sprite 0 Answers
Ask some problem about rotation, quaternion and angle 0 Answers