Joystick Sensor Axis: axisValues

axisValues
  • Returns the amount the joystick has been moved from the center

Type: 
  • list [ x, y, z, zRot]

x: left/right direction

  • Type:  integer
  • Range: 32767 to -32676
y: up/down (front/back)
  • Type:  integer
  • Range: 32767 to -32767
z:  throttle paddle
  • Type:  integer
  • Range: 32767 to -32767
zRot: rotation (twist)
  • Type:  integer
  • Range: 32767 to -32767
Joystick Axis Sensor:
  • Mostly used when All Events selected
  • 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).
Sample Code


################  Get amount the joystick has been moved from the center

# import bge module
import bge

# get the controller
cont = bge.logic.getCurrentController()

# get the sensor attached to the controller
# my sensor is named Turn

sen = cont.sensors["Turn"]

# get the amount joystick has been moved from the center
movement = sen.axisValues

# get the amount joystick has been moved left/right
left_right = movement[0]

# get the amount joystick has been moved front/back
front_back = movement[1]

# get the amount paddle has been moved
paddle = movement[2]
 
# get the joystick rotation
rotation = movement[3]