Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bge
- from bge import logic
- from bge import constraints
- def main():
- cont = bge.logic.getCurrentController()
- own = cont.owner
- parts = []
- for child in own.childrenRecursive:
- if 'SpawnPart' in child:
- child.removeParent()
- added = own.scene.addObject(child['SpawnPart'],child,0)
- parts.append(added)
- child.endObject()
- for part in parts:
- if 'Joint' in part:
- for part2 in parts:
- if part2.name ==part['Joint']:
- angle = part['Angle'].split(',')
- new = []
- for entry in angle:
- new.append(float(entry))
- angle =new
- # get object named Object1 and Object 2
- object_1 = part
- object_2 = part2
- # 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 = 0.0
- edge_position_y = 0.0
- edge_position_z = 0.0
- # rotate the pivot z axis about 90 degrees
- edge_angle_x = angle[0]
- edge_angle_y = angle[1]
- edge_angle_z = angle[2]
- # 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,flag=128)
- own.endObject()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement