Keyboard input help
Cpt.Dallas
Member Posts: 6
I'm trying to make a top down game at the moment and am running into problems with keyboard input. I'm using keyboard inputs to move the character around (UP, Down, Left and Right arrow keys), which is working just fine.
I have it set up so that when the Up arrow key is pressed the image changes to the character facing up, the Down key changes the image down and so on (I've created several images to show all directional movement).
This all works okay until I want the character to move diagonally. I've set up code so that when Up & Right arrows keys are pressed together the image should change to a diagonal image, but it doesn't. It either shows the Up image or the Right image (at random).
What am I missing?
Comments
The logic doesn't know that you want it to only follow the diagonal rules when you're pressing both up and right at the same time. Instead, it's firing the up behaviors AND the right behaviors, competing with themselves. To fix this, put them all in one rule and its "otherwise" section. Begin with the diagonal presses first. So it will check if Up AND Right is pressed. Otherwise, it will check if Up AND Left is pressed. Otherwise, it will check if Down AND Right is pressed…and so on.
Thanks Adrenaline
It now works perfectly!!