Joystick direction
Blitz3D Forums/Blitz3D Programming/Joystick direction
| ||
Hi, I just bought a joypad/controller thingy with two analog sticks (kind of like the ps2 controller). I want the left one to control my player. I know about joyx() and joyy() commands, but I would like to know how I can combine these two values to get two parameters : - the direction (in degrees) that I need to move my player. - the "speed" with which I need to control my player in that direction (this can be a number between 0 and 1.0 or something, I can always multiply it to get the right speed in my game) The solution is probably simple, but I just can't seem to come up with it right now. Any advice would be greatly appreciated |
| ||
Okay, I think I figuered it out : angle# = ATan2(-joyx(),-joyy()) ^ (in my case I need to take the negativs, but that's dependant of your camera angle I suppose) speed# = abs(joyx())+abs(joyy()) if speed>1.0 then speed=1.0 Seems to work fine... |
| ||
We knew you would :) |