Joystick Sensor Axis: axis

axis
  • gets/sets the type of axis and direction of motion

Type: 
  • list [axis, motion]

axis:

  • Type:  integer
     
  • 1 = x & y axis (left/right & front/back)
     
  • 2 = joystick twist (left/right) & Paddle 

motion -- X & Y Axis:

  • Type:  integer
     
  • 0 = Right Axis
     
  • 1 = Up Axis
     
  • 2 = Left Axis
     
  • 3 = Down Axis

motion -- Twist Axis/Paddle:

  • Type:  integer
     
  • 0 = Down (Paddle)
     
  • 1 = Counter Clockwise (Joystick twist)
     
  • 2 = Up (Paddle)
     
  • 3 = Clockwise (Joystick twist)
Joystick Axis Sensor:
  • If the 'All Events' toggle button is selected, this variable has no effect.
  • 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 the joystick axis & direction

# 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 joystick axis & direction
axis_direction = sen.axis
 
Sample Code


################  Set the joystick axis & direction

# 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"]

# set the joystick axis & direction
sen.axis = [ 1, 0 ]