Ragdoll = bge.logic.getCurrentScene().addObject('RagdollGroupInstance,own,0)
Armature = bge.logic.getCurrentScene().addObject(own['ArmCopyOnHiddenLayer',own,0)
for const in Armature.constraints:
for bones in eval(Ragdoll['RagBones']):
if bones.name==const.name:
const.target=bones
but a issue I am having is eval(Ragdoll[‘Ragbones’])
throws a error,
it contains
the string - [‘MCH-forearm.L’,‘MCH-upper_arm.L’,‘MCH-head’,‘MCH-neck’,‘MCH-chest.001’,‘MCH-chest.002’,‘MCH-hips’,‘MCH-forearm.R’]
import bge
import ast
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
print('Fire')
##add ragdoll on actor death
Ragdoll = bge.logic.getCurrentScene().addObject('addObb.001',own,0)
Armature = bge.logic.getCurrentScene().addObject(own['Armature'],own,0)
print(Ragdoll['RagBones'])
x = Ragdoll['RagBones']
x2 = Ragdoll['RagBones2']
list1 = ast.literal_eval(x)
list1 = [i.strip() for i in list1]
list2= ast.literal_eval(x2)
list2 = [i.strip() for i in list2]
list1 = list1+list2
print(list1)
for const in Armature.constraints:
print(str(const)+" is the name of the constraint")
for bones in list1:
print(str(const)+" is checking "+str(bones))
print(bones)
if const.name==bones+": Copy Rotation":
const.target=bones
for objects in own.childrenRecursive:
if 'Actor1CameraHook' in objects:
objects.removeParent()
cam =bge.logic.getGetCurrentScene().active_carmera
if cam['Target']==own:
bge.logic.getGetCurrentScene().active_carmera.suspendDynamics()
cam['Target']="Empty"
if 'CamTarget' in objects:
objects.removeParent()
own.endObject()
main()
but I am having issues with the constraint names format not matching each other
edit: I think it’s because they were added using diff versions, I will clear them all and add them back
Because it executes any Python code that is in that string … it could even clean your hard disk ;).
Why is there a string in this property? It does not look like you entered that manually.
Why didn’t you added a list instead? That is what you finally expect.