Input.pressed not firing every time


(Mike Evmm) #1

Just like the title implies, sometimes (some builds) Input.pressed will fire whenever the checked key is pressed, and sometimes it won’t. Seems absolutely random. It’s also not the first time I’ve had this problem, so I suspect it’s not the project’s fault (though it may very well be).


(Darrin) #2

Hi, never had a problem with it. Probably need more info, ie the code.


(Jacob Albano) #3

I’ve had this problem myself, though I’m not sure what causes it. Some code would probably help, I guess? I assume you’re not doing anything too strange though.


(Mike Evmm) #4

Well, for instance, half-“borrowed” form the pink demo:

if (onSolid && Input.check("JUMP"))
{
	spdY = JUMP;
	onSolid = false;
	spdX *= LEAP;
}

This only fires sometimes.
(Oh, and Merry Whatever-you-celebrate!)


(Jacob Albano) #5

Are you doing anything strange with your project? Framerate higher than 60, that kind of thing?


(Mike Evmm) #6

Not really, standard super, non-fixed framerate, 60fps.


(Zachary Lewis) #7

A few things I instantly notice:

  1. This is using Input.check(), not Input.pressed(). I’m sure this is obvious, but Input.pressed() would never fire in this code, since it isn’t there.
  2. If onSolid is false, the input check would not occur, since the conditional would perform an early-out. This would cause the Input.check() function to not fire if the player is not on a solid object, which I also believe is the desired effect.

Are you expecting either of these cases to work differently?


(Mike Evmm) #8
  1. Yes, of course, that’s a typo, sorry.
  2. Well, this might be the issue. Every time I’ve faced this problem (usually with jumps, regular and wall-jumps) an extra condition is being checked. I’m thinking specifically of a wall jump case, in which collide(x+1)||collide(x-1) was being checked, along with Input.pressed("JUMP"). I had to press the button twice or thrice to make the character jump, but it would jump eventually, making it odd that it was the value of collide changing.