Physics Constraints (bge.constraints)¶
Basic Physics Constraint
++++++++++++++++++++++++
Example of how to create a hinge Physics Constraint between two objects.
from bge import logic
from bge import constraints
# get object list
objects = logic.getCurrentScene().objects
# get object named Object1 and Object 2
object_1 = objects["Object1"]
object_2 = objects["Object2"]
# want to use Edge constraint type
constraint_type = 2
# get Object1 and Object2 physics IDs
physics_id_1 = object_1.getPhysicsId()
physics_id_2 = object_2.getPhysicsId()
# Use bottom right edge of Object1 for hinge position
edge_position_x = 1.0
edge_position_y = 0.0
edge_position_z = -1.0
# use Object1 y axis for angle to point hinge
edge_angle_x = 0.0
edge_angle_y = 1.0
edge_angle_z = 0.0
# create an edge constraint
constraints.createConstraint(physics_id_1, physics_id_2,
constraint_type,
edge_position_x, edge_position_y, edge_position_z,
edge_angle_x, edge_angle_y, edge_angle_z)
-
bge.constraints.
createConstraint
(physicsid, physicsid2, constrainttype, [pivotX, pivotY, pivotZ, [axisX, axisY, axisZ, [flag]]]])¶ Creates a constraint.
Parameters: POINTTOPOINT_CONSTRAINT
LINEHINGE_CONSTRAINT
ANGULAR_CONSTRAINT
CONETWIST_CONSTRAINT
VEHICLE_CONSTRAINT
GENERIC_6DOF_CONSTRAINT
Parameters:
-
bge.constraints.
error
¶ Simbolic constant string that indicates error.
-
bge.constraints.
exportBulletFile
(filename)¶ export a .bullet file
Parameters: filename (string) – File name
-
bge.constraints.
getAppliedImpulse
(constraintId)¶ Parameters: constraintId (int) – The id of the constraint. Returns: the most recent applied impulse. Return type: float
-
bge.constraints.
getVehicleConstraint
(constraintId)¶ Parameters: constraintId (int) – The id of the vehicle constraint. Returns: a vehicle constraint object. Return type: bge.types.KX_VehicleWrapper
-
bge.constraints.
getCharacter
(gameobj)¶ Parameters: gameobj ( bge.types.KX_GameObject
) – The game object with the character physics.Returns: character wrapper Return type: bge.types.KX_CharacterWrapper
-
bge.constraints.
removeConstraint
(constraintId)¶ Removes a constraint.
Parameters: constraintId (int) – The id of the constraint to be removed.
-
bge.constraints.
setCcdMode
(ccdMode)¶ Note
Very experimental, not recommended
Sets the CCD (Continous Colision Detection) mode in the Physics Environment.
Parameters: ccdMode (int) – The new CCD mode.
-
bge.constraints.
setContactBreakingTreshold
(breakingTreshold)¶ Note
Reasonable default is 0.02 (if units are meters)
Sets tresholds to do with contact point management.
Parameters: breakingTreshold (float) – The new contact breaking treshold.
-
bge.constraints.
setDeactivationAngularTreshold
(angularTreshold)¶ Sets the angular velocity treshold.
Parameters: angularTreshold (float) – New deactivation angular treshold.
-
bge.constraints.
setDeactivationLinearTreshold
(linearTreshold)¶ Sets the linear velocity treshold.
Parameters: linearTreshold (float) – New deactivation linear treshold.
-
bge.constraints.
setDeactivationTime
(time)¶ Sets the time after which a resting rigidbody gets deactived.
Parameters: time (float) – The deactivation time.
-
bge.constraints.
setDebugMode
(mode)¶ Sets the debug mode.
- Debug modes:
Parameters: mode (int) – The new debug mode.
-
bge.constraints.
setGravity
(x, y, z)¶ Sets the gravity force.
Parameters:
-
bge.constraints.
setLinearAirDamping
(damping)¶ Note
Not implemented.
Sets the linear air damping for rigidbodies.
-
bge.constraints.
setNumIterations
(numiter)¶ Sets the number of iterations for an iterative constraint solver.
Parameters: numiter (int) – New number of iterations.
-
bge.constraints.
setNumTimeSubSteps
(numsubstep)¶ Sets the number of substeps for each physics proceed. Tradeoff quality for performance.
Parameters: numsubstep (int) – New number of substeps.
-
bge.constraints.
setSolverDamping
(damping)¶ Note
Very experimental, not recommended
Sets the damper constant of a penalty based solver.
Parameters: damping (float) – New damping for the solver.
-
bge.constraints.
setSolverTau
(tau)¶ Note
Very experimental, not recommended
Sets the spring constant of a penalty based solver.
Parameters: tau (float) – New tau for the solver.
-
bge.constraints.
setSolverType
(solverType)¶ Note
Very experimental, not recommended
Sets the solver type.
Parameters: solverType (int) – The new type of the solver.
-
bge.constraints.
setSorConstant
(sor)¶ Note
Very experimental, not recommended
Sets the successive overrelaxation constant.
Parameters: sor (float) – New sor value.
-
bge.constraints.
setUseEpa
(epa)¶ Not implemented.
-
bge.constraints.
DBG_NODEBUG
¶ Note
Debug mode to be used with function
setDebugMode
No debug.
-
bge.constraints.
DBG_DRAWWIREFRAME
¶ Note
Debug mode to be used with function
setDebugMode
Draw wireframe in debug.
-
bge.constraints.
DBG_DRAWAABB
¶ Note
Debug mode to be used with function
setDebugMode
Draw Axis Aligned Bounding Box in debug.
-
bge.constraints.
DBG_DRAWFREATURESTEXT
¶ Note
Debug mode to be used with function
setDebugMode
Draw freatures text in debug.
-
bge.constraints.
DBG_DRAWCONTACTPOINTS
¶ Note
Debug mode to be used with function
setDebugMode
Draw contact points in debug.
-
bge.constraints.
DBG_NOHELPTEXT
¶ Note
Debug mode to be used with function
setDebugMode
Debug without help text.
-
bge.constraints.
DBG_DRAWTEXT
¶ Note
Debug mode to be used with function
setDebugMode
Draw text in debug.
-
bge.constraints.
DBG_PROFILETIMINGS
¶ Note
Debug mode to be used with function
setDebugMode
Draw profile timings in debug.
-
bge.constraints.
DBG_ENABLESATCOMPARISION
¶ Note
Debug mode to be used with function
setDebugMode
Enable sat comparision in debug.
-
bge.constraints.
DBG_DISABLEBULLETLCP
¶ Note
Debug mode to be used with function
setDebugMode
Disable Bullet LCP.
-
bge.constraints.
DBG_ENABLECCD
¶ Note
Debug mode to be used with function
setDebugMode
Enable Continous Colision Detection in debug.
-
bge.constraints.
DBG_DRAWCONSTRAINTS
¶ Note
Debug mode to be used with function
setDebugMode
Draw constraints in debug.
-
bge.constraints.
DBG_DRAWCONSTRAINTLIMITS
¶ Note
Debug mode to be used with function
setDebugMode
Draw constraint limits in debug.
-
bge.constraints.
DBG_FASTWIREFRAME
¶ Note
Debug mode to be used with function
setDebugMode
Draw a fast wireframe in debug.
-
bge.constraints.
POINTTOPOINT_CONSTRAINT
¶ Note
Constraint type to be used with function
createConstraint
-
bge.constraints.
LINEHINGE_CONSTRAINT
¶ Note
Constraint type to be used with function
createConstraint
-
bge.constraints.
ANGULAR_CONSTRAINT
¶ Note
Constraint type to be used with function
createConstraint
-
bge.constraints.
CONETWIST_CONSTRAINT
¶ Note
Constraint type to be used with function
createConstraint
-
bge.constraints.
VEHICLE_CONSTRAINT
¶ Note
Constraint type to be used with function
createConstraint
-
bge.constraints.
GENERIC_6DOF_CONSTRAINT
¶ Note
Constraint type to be used with function
createConstraint