- Home /
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
Answer by Austin 3 · Dec 14, 2010 at 08:19 AM
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
Answer by BerggreenDK · Dec 09, 2010 at 07:30 AM
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.
Answer by diabloroxx · Dec 13, 2010 at 09:57 PM
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.
I justed changed ST$$anonymous$$.mainLoop.volume += 0.005f; to -= and kept the input key as "right" and it works perfectly. I have no idea what the problem is.
AND, sorry for spam$$anonymous$$g, I just swapped my code for the "left" input (which lowers the volume) with "right" and change the "right" input check to left and it's working fine also!
Your answer
Follow this Question
Related Questions
How to get the key from the button name 1 Answer
Key remapping inGame 0 Answers
how can i use getkey and getkeydown for two diffrent functions. 2 Answers
replace Input.GetKey for mobile input 1 Answer
Only KeyPress once? 1 Answer