Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
1  
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)? –  Kylotan Feb 21 '13 at 12:28

1 Answer 1

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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.