This happens if W is held and left shift is NOT held. (If GetKey(Ke圜ode.W) & GetKey("left shift")) This happens if W is held and left shift IS held. in this case, our 3rd branch is a catch all, if I did this right. It's best you prioritize your if/else if/else branches so that you can code these conditions without over-convoluting things and having a minimal amount of branches. GetKeyUp = the user just released the key. GetKey = the user is holding the key down currently GetKeyDown = when the user first presses the key Just a quick primer, in case you don't already know: Then structure your if/else if/else conditions to cover all these different branches. this may be a first I'd recommended it, however) and just figure out the different scenarios that lead to walk, run, and idle. I think that your best is to do sort of a flowchart (man, one of my old instructors would be proud. (this is just so that it doesn't fall into the idle animation) If getkeydown left shift, and getkey (no reference down/up) W. Using GetKey should work though, but it is probably causing some unnecessary processing though. You can use GetKeyDown for doing something when the key is initially pressed down, and GetKeyUp for when the key is released. That will require some changes to the logic, so I hope you can figure out how that should work. Just need to do it once, and when you release the keys, you can unset if necessary. You wouldn't want to repeatedly set these bools the entire time the key is held down. It will allow you to set up controls that work across multiple platforms or controllers.Īlso, I typed the above due to lazyness and lack of time, sorry. Lastly, just my own suggestion, read up on the input manager.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |