Physics Constraints 6 DOF Rotating Motor: setParam

setParam(axis, min, max)
  • movement on the x, y and z axis.
     
  • Object 2 moves.  But uses Object 1 axis to move on.

axis: 
  • Type: integer
     
  • 0 = x axis
     
  • 1 = y axis
  • 2 = z axis
     
  • 3 = x axis rotation
     
  • 4 = y axis rotation
     
  • 5 = z axis rotation
min:
  • minimum distance (0.0 is Object 2 object center)
     
  • Type: float

max:

  • maximum distance (0.0 is Object 2 object center)
     
  • Type: float
setParam(axis, speed, acceleration)
  • Linear/Rotational Motor
     
  • Object 2 moves.  But uses Object 1 axis to move on

axis: 
  • Type: integer
     
  • 6 = x axis linear
     
  • 7 = y axis linear
     
  • 8 = z axis linear
     
  • 9 = x axis rotation
     
  • 10 = y axis rotation
     
  • 11 = z axis rotation
speed:
  • movement speed
     
  • Type: float
acceleration:
  • acceleration
     
  • Type: float
setParam(axis, stiffness, elasticity)
  • Linear/Rotational Spring
     
  • Object 2 moves.  But uses Object 1 axis to move on.

axis: 
  • Type: integer
     
  • 12 = x axis
     
  • 13 = y axis
     
  • 14 = z axis
     
  • 15 = x axis rotation
     
  • 16 = y axis rotation
     
  • 17 = z axis rotation
stiffness:
  • stiffness of the spring.
     
  • Type: float
elasticity:
  • Tendency of the spring to return to its original shape.
     
  • Type: float
Sample Code

 

################  create a rotating motor

# import bge
import bge

# get current scene
scene = bge.logic.getCurrentScene()

# get object list
objList = scene.objects

# get object named Cube_Green
obj1 = objList["Cube_Green"]

# get object named Cube_Red
obj2 = objList["Cube_Red"]

# want to use a 6DOF constraint
constraintType = 12

# get obj1 physics ID
obj1_ID = obj1.getPhysicsId()

# get obj2 physics ID
obj2_ID = obj2.getPhysicsId()

# Use the object center of obj1 for pivot point
pivotPos_X =  0.0
pivotPos_Y =  0.0
pivotPos_Z = 0.0

# create a 6DOF constraint
cube_6DOF = bge.constraints.createConstraint( obj1_ID, obj2_ID,
 constraintType,
 pivotPos_X, pivotPos_Y, pivotPos_Z)

# set rotation around pivot x and y axis to zero
cube_6DOF.setParam(3, 0.0, 0.0)
cube_6DOF.setParam(4, 0.0, 0.0)

# create rotational motor around the pivot z axis
# speed of 100.0  Acceleration of 0.3
cube_6DOF.setParam(11, 100.0, .3)