Difficult to use Joystick Controls

Greetings.

I am currently working on a split screen shooter game that is very basic and is more of a proof of concept game than one that is actually meant to be played.

I have been messing with using a joystick to control one player, and the mouse and keyboard to control the other.

My issue lies in the fact that it is incredibly difficult to use the joystick.

I found that the most issues are in aiming (using the right axis). Because I’m using a mouse input for player 1, player 2 cannot be simulated with a mouse, therefore the right axis simulates pressing the arrow keys and the arrow keys control the rotational motion. The issue with this is that, unlike with a mouse, the rotation is a set speed that occurs immediately.

To be a little more specific, with a mouse you can inch the mouse very slightly to right to look very slightly to the right. However with my joystick system you go a full increment of rotation to the right if you barely push the stick over.


This is the in game logic. The left arrow key rotates the player 2 degrees on the Z-axis, and the right arrow keys rotates the player -2 degrees on the Z-axis.


This is the program that maps the controller to my computer. The boxed area represents the right axis. Up on the right axis is mapped to the up arrow, left on the axis is mapped to the left arrow, etc.

So when I barely move the right stick the player rotates a full 2 degrees (or -2 degrees), making it incredibly difficult to aim. I could lower the degrees that it rotates by, but that would lower the overall sensitivity and although making aiming easier, it would take ages just to do a 180.

I tried messing with torque, however with the torque setting the player STARTS to spin correctly, however the player will continue to rotate after you release the key.

I’m not experienced with python whatsoever, I work with logic whenever I can. But I’m not opposed to using it if necessary, however I’ll need a little more help in understanding it.

I’m not sure I worded that very well but that’s the best way I can describe it. If anyone can provide assistance, I’d be eternally grateful.

Thanks in advance.

Really, when you use Simple motion (with loc or rot as in your case) you are teleporting your object. Before you active your button your object is on 0 degrees. After you push your button your object is on 2 degress. You didn’t have any transition (i.e 0º- 0.5º - 1º, etc).If you use a force/torque parameter you are using forces and momentums and therefore when you stop of applying these forces or momentums the object can not stop immediately as it has to behavior as a dynamic object (it will stop when floor friction or other force stop it)

To benefit from the sensitivity of the joystick you need to trigger a Python controller that reads the current input of the joystick axis. This way you can get fast turnings when the joystick is turned more and slow turns when the joystick is turned just a little.

The logic bricks do not support you on that. With logic bricks alone an axis acts like a button press. They are more or less looking for yes and no rather than e.g. 93% ;).

With a python controller you can calculate the value of the joystick axis and calculate the turn angle or an animation frame from it. This can be applied to the game object or to other logic bricks (e.g. an motion actuator).

here a small script to get you started with controller function trough python.

import bge.logic as logic

cont = logic.getCurrentController()
player = cont.owner


joy = cont.sensors['Joystick']
aXis = joy.axisValues


# Store the axis positions / 100,000 in variables
axisx = aXis[0] * 0.00001
axisy = aXis[1] * -0.00001


# if the joystick position in within 1500 of the center, then zero it out (1800 or 2000 works better on some joysticks)
if axisx < 0.01500 and axisx > -0.01500:
    axisx = 0   
if axisy < 0.01500 and axisy > -0.01500:
    axisy = 0

better to use:

bge.logic.joysticks[0].axisValues

then the values are normalized already (-1 to 1) and dont require joystick sensors, just an always with true pulse.

Thanks for the responses.

Sorry to be so helpless, but how would I set up that logic with the associated script? Like, what logic would I need to connect this to? Of course I’d need a controller, but I’m not sure what to do from there (maybe I don’t understand as much about blender as I thought I did? lol).

Joystick sensor -> Python controller

Basically the joystick sensor senses a change on the input (e.g. different axis value).
When there is a change sensor triggers the connected controllers.

You python controller can read the current axis value and apply this process this change (e.g. transform it into an according rotation).

Thanks for the reply, I really appreciate it.

I’ll try this out when I get a free moment, hopefully I can make this work.