Advertisement
Guest User

ragdoll

a guest
Oct 13th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.03 KB | None | 0 0
  1. import bge
  2. from bge import logic
  3. from bge import constraints
  4.  
  5. def main():
  6.  
  7.     cont = bge.logic.getCurrentController()
  8.     own = cont.owner
  9.     parts = []
  10.     for child in own.childrenRecursive:
  11.         if 'SpawnPart' in child:
  12.             child.removeParent()
  13.             added = own.scene.addObject(child['SpawnPart'],child,0)
  14.             parts.append(added)
  15.            
  16.             child.endObject()
  17.     for part in parts:
  18.         if 'Joint' in part:
  19.             for part2 in parts:
  20.                 if part2.name ==part['Joint']:
  21.                     angle = part['Angle'].split(',')
  22.                     new = []
  23.                     for entry in angle:
  24.                         new.append(float(entry))
  25.                    
  26.                     angle =new
  27.                     # get object named Object1 and Object 2
  28.                     object_1 = part
  29.                     object_2 = part2
  30.  
  31.                     # want to use Edge constraint type
  32.                     constraint_type = 2
  33.  
  34.                     # get Object1 and Object2 physics IDs
  35.                     physics_id_1 = object_1.getPhysicsId()
  36.                     physics_id_2 = object_2.getPhysicsId()
  37.  
  38.                     # use bottom right edge of Object1 for hinge position
  39.                     edge_position_x = 0.0
  40.                     edge_position_y = 0.0
  41.                     edge_position_z = 0.0
  42.  
  43.                     # rotate the pivot z axis about 90 degrees
  44.                     edge_angle_x = angle[0]
  45.                     edge_angle_y = angle[1]
  46.                     edge_angle_z = angle[2]
  47.  
  48.                     # create an edge constraint
  49.                     constraints.createConstraint(physics_id_1, physics_id_2,
  50.                                                  constraint_type,
  51.                                                  edge_position_x, edge_position_y, edge_position_z,
  52.                                                  edge_angle_x, edge_angle_y, edge_angle_z,flag=128)        
  53.                            
  54.     own.endObject()        
  55. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement