move once per click

I'm making a very simple game, that involves something happening when a button is pushed. Trouble is though, when I click the button the action I want happens two or three and sometimes four times. I'm not even sure what part of my code to share. I have an interact file that I got from somewhere else, and I don't even understand most of what is in there. That's where the pushing of the buttons occurs. In my game file, I just have to say what happens when each button is pushed. I have a callback loop which checks for input every cycle. I'm not sure how to fix this. Any ideas?
you need one of two things.
first, check your tools to see if you have a keyup and keydown. If so, you perform the action only after getting both within a tiny amount of time, say 1/3 of a second maybe, you can mess with the value until happy. The timer here is extra -- without it you can let them hold it down for a long time and when let go it fires, that may be ok for some things

if you lack that, you can still do a timer..
once you notice it has been pressed, do the action, and then prevent doing the action again for some period of time (here again, play with the value until satisfied). Holding it down here will repeat the action but not until after that time period. Or, swap to a tool that has the keyup keydown idea if this does not work for you.
Last edited on
Topic archived. No new replies allowed.