using a gamepad how do i test for a specific range in x/y axis
I'm making a sidescroller with a 2d character. The character can aim his weapon in 8 directions. So far i can aim left, right, up, and down. I need to create a test that checks whether I'm currently pressing diagonally up or diagonally down on the left analog stick and then returns a bool. The bool will then be used to adjust the animation state. There needs to be an equal range of motion between all 8 possible axis states so that the character animates smoothly. Currently I can detect the various diagonal quadrants but the animations interfere with each other. For example if i set the diagonal SouthEast quadrant the character will fire the diagonal down animation instead of the running right animation and it also replaces the look down animation. I need to know how to reduce the viable range this will equal true by about 30 %. Also I don't really know anything about vector math so if I'm doing something wrong or there is an easier way please let me know.
Ok, so I was trying to make this way more complicated than it needed to be. Here is the solution. It is actually very similar to the first solution I tried but I guess I didn't plug in the right numbers. Anyways, it still needs tweaked abit but it works as a diagonal test.
answered Apr 12 '15 at 12:02 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here