Please use the proper tags for code snippets.
The way I understand your code is:
During this frame you do:
- If the Q button was pressed down this frame you set
qwaspressed = true;
- If the Q button was pressed down this frame and if
qwaspressed
you set it to false
So you have 2 scenarios here:
A) Button Q was not pressed this frame so nothing happens.
B) Button Q was pressed this frame so 1) happens, then 2) happens as well because you have just set theqwaspressed
condition to true and we already know the button was pressed. This leads to the variableqwaspressed
being false again.
FixedUpdate gets called (0 or more times) before Update in the game loop. So it will get called next frame. Whats important here is that its execution happens separate from Update,its not magic, and by that point qwaspressed
will be false,as its only true for a brief moment when scenario B) happens.
I think your problem comes from a lack of understanding regarding how C# and programming in general works.Id greatly recommend visiting the introduction of C# on msdn(microsoft), or going through a tutorial on the basics of C# or any programing language for that matter,as long as they teach you control structures(how code is executed), as otherwise it will be very hard to make any progress.
P.S. This question seems more fitting to the scripting forum as the issue has little to do with the Input System.