Game Object: applyRotation

applyRotation(rot, local)
  • Rotate the game object a set amount (works like Motion Actuator Rot).

rot:
  • Amount to rotate the game object.
  • Type: list [ rx, ry, rz]
     
  • rx: amount in radians to rotate on the x-axis
     
  • ry: amount in radians to rotate on the y-axis
     
  • rz: amount in radians to rotate on the z-axis
local:
  • axis (world or local) used to rotate the game object.
  • Type:  boolean
  • 0 = False = world axis
  • 1 = True = local axis
Note:
  • Object types: Dynamic, Rigid body, Static, Character, Sensor, Occlude and No Collision.
     
  • Radians: a unit of angle. 1 radian is approximately 57.296 degrees.  1.570796327 radians = 90 degrees
Sample Code

################## Rotate the game object a set amount
  

# import bge
import bge

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

# get object that controller is attached to
obj = cont.owner

# rotate the game object 1.570796327 radians (90 degrees)
rot = [ 0.0, 0.0, 1.570796327]

# use the world axis
local = False

# apply rotation
obj.applyRotation(rot,local)