5
\$\begingroup\$

I'm trying to make my own first person camera controls in unity that use both thumbsticks on a joypad. I have this working fine. However, when I move the right thumb stick (the one uses to look left / right & up / down the camera begins to constantly update.

Here is my joypad movement code:

   // Update is called once per frame
void Update()
{

    float speed = transform.localEulerAngles.y + Input.GetAxis("LeftRight") * sensitivityX;

    rotationY += Input.GetAxis("UpDown") * sensitivityY;
    rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);

    transform.localEulerAngles = new Vector3(-rotationY, speed, 0);

}

To control the left thumb stick, I've simply attached the my script to a first person character controller Unity provide.

I know my code is updating every frame, but I assumed that it would only update as and when I press the right thumb stick. If that isn't the case, is there a way I can limit it to only increment when I move the right thumb stick?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Did you try using Debug.Log to show what the GetAxis call is saying? And check the dead zone values on the input manager? Didn't I suggest this before in a very similar post a few days ago (which has now strangely disappeared)? \$\endgroup\$
    – Kylotan
    Commented Feb 21, 2013 at 12:28

1 Answer 1

3
\$\begingroup\$

Your code looks fine, so I assume the problem is somewhere else. The one I can think of: these axes have very small "Gravity" value in Input Manager (i.e. "Speed in units per second that the axis falls toward neutral when no buttons are pressed", from this page in Unity Manual).

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .