2
Basic Physics Constraint
3
++++++++++++++++++++++++
4
Example of how to create a hinge Physics Constraint between two objects.
7
from bge import constraints
10
objects = logic.getCurrentScene().objects
12
# get object named Object1 and Object 2
13
object_1 = objects["Object1"]
14
object_2 = objects["Object2"]
16
# want to use Edge constraint type
19
# get Object1 and Object2 physics IDs
20
physics_id_1 = object_1.getPhysicsId()
21
physics_id_2 = object_2.getPhysicsId()
23
# Use bottom right edge of Object1 for hinge position
26
edge_position_z = -1.0
28
# use Object1 y axis for angle to point hinge
33
# create an edge constraint
34
constraints.createConstraint(physics_id_1, physics_id_2,
36
edge_position_x, edge_position_y, edge_position_z,
37
edge_angle_x, edge_angle_y, edge_angle_z)