Joystick sensor

Moving the joystick in the selected Axis Direction sends a positive pulse to the connected controller(s). Returning the joystick to the center sends a negative pulse to the connected controller(s).

Option(s) of the Mouse sensor :

Python :

# import bge module
import bge
 
# get the controller
cont = bge.logic.getCurrentController()
 
# get the sensor attached to the controller
# my sensor is named Trigger
sen = cont.sensors["Trigger"]
  • sens.axis : Get/set the type of axis and direction of motion ( list / [axis, motion]
    • with axis : 1 = x & y axis (left/right & front/back) , 2 = joystick twist (left/right) & Paddle
    • with motion : ( axis = 1 ) 0 = Right Axis , 1 = Up Axis , 2 = Left Axis , 3 = Down Axis // ( axis = 2 ) : 0 = Down (Paddle) , 1 = Counter Clockwise (Joystick twist) , 2 = Up (Paddle) , 3 = Clockwise (Joystick twist)
  • sen.axisValues : Returns the amount the joystick has been moved from the center ( list / [ x, y, z, zRot] )
    • with x : left/right direction (32767 to -32767)
    • with y : up/down (front/back) (32767 to -32767)
    • with z : throttle paddle (32767 to -32767)
    • with zRotl : rotation (twist) (32767 to -32767)
  • sen.connected : Returns if the selected joystick is connected to the sensor (Boolean)
  • sen.index : gets/sets which joystick is being used (integer / 0-7) // Up to 8 joysticks can be connected
  • sen.numAxis : Returns the number of axes that the joystick has
  • sen.threshold : gets/sets the amount the joystick has to move from the center position before the sensor is triggered ( integer / 32767 to -32767 )
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License