Last night while dogsitting, I finally decided to suck it up and attempt to program analog joystick movement and view controls in the BGE. To my surprise, I’ve mostly succeeded! Just one problem remains though- I have the player moving in the direction of the left stick, and at a speed relative to how far the player has pressed the stick, but in order to complete my 3rd person game setup, the ‘forward left stick’ direction needs to point in the direction opposite the camera. (If you need an example of this kind of setup, I think it’s used in just about every modern 3rd person game, but the Uncharted series comes readily to mind.)
The camera is parented to the object ‘PEmpty’ which the right stick rotates. I tried creating another empty ‘EmptyDir’ which is also parented to ‘PEmpty’ and grabing its position to obtain the vector of the camera direction. However, as you might expect (lol), it doesn’t work, and I’m stumped.
If you uncomment line 34 in ‘analog.py’ (and comment lines 30 and 31), you will obtain the behavior that does not take the camera angle into account - this is a little hackish, I think, but it’s how I was able to get it working ;). In its current broken state, in lines 30 and 31 I’m attempting to use a similar method, but taking the camera into account.
What’s going wrong here? : /
P.S. Apologies for use of magic numbers, and a messy, unoptimized script- I was so excited I wanted to get it to work first, with the intention of cleaning it up later.
AnalogTestPack.blend (480 KB)