Very wierd issue with right arrow key

So I have a script right now that just edits the volume. When you hold the left key, the volume is lowered. When you hold the right key, the volume is suppose to be raised, but it only raises the volume for maybe 1 second or two and the stops. I then have to lift my finger from the key and repress and it will do it again. I changed the key to "k" to see if it was an issue with the logic and it isn't, the other key raised the volume fine without stopping.

        if (Input.GetKey("right") || (Input.GetAxis("Horizontal") == -1 && mainMenu.time > delta)) {
            changesMade = true;
            mainMenu.time = 0.0f;
            if (barPosition == numOptions)
                barPosition += 1;

            if (barPosition == 0)
                STM.mainLoop.volume += 0.005F;
        }

If anyone has any ideas please toss them out.

EDIT: The problem is only with the key input, the controller works fine.

Thanks! - Austin

Perhaps your input settings for controls needs ajustment. You might need a better sensiblity or deadzone.

Show us a bit of your code, if you think is a problem with the actual algorithm. Descriping the problem without showing the reason makes it harder to understand and help you.

 if (Input.GetKey("right"))
          Debug.Log("right pressed");

This keeps working perfectly when inside the Update(). Check your code or perhaps, the Input. Maybe you have another Camera/Controller attached to the "Right" key which is disabling it from Multiple presses.

Okay, I figured out the problem. I was looking at two different inputs to carry out some logic in the if statement, right? Well, "Horizontal", I had forgotten, also takes in keystrokes so it was clashing with the "right" and "left" checks; that is why all the weird stuff was happening. I've gotten rid of the first check (Input.GetKey("right") and "left") and I'm just using the Input Manager. Thanks all for your ideas/help, I really do appreciate it.

  • Austin