M
Matt93
Guest
Hi fellow Game Makers!
I'm using the physics system, and working on a project which has a ragdoll. This is made of 10 instances of a 'body' object, and 1 instance of a 'head' object. These are created in an obj_ragdoll_create object. My code for this is here:
Obj_ragdoll_body and obj_ragdoll_head are parented to a ragdoll parent.
When any part of the ragdoll collides with a 'hole' object, I want the entire ragdoll to be destroyed. The game involves catapulting ragdolls continuously towards this hole, so there will always be more than one in the room.
Simply calling with (obj_ragdoll_body) instance_destroy causes all instances to be destroyed. Destroying the parent upon collision also doesn't seem to work. I have also tried looping through instance_nearest using the repeat function, but this also doesn't seem to work. Any ragdolls which miss the hole are just meant to stack up nearby, without being destroyed, so these can sometimes be the nearest instances.
I'm quite stuck on this, as I don't just want the instances in collision to be destroyed, but all instances attached to it, without destroying the other ragdolls in the room.
Any help would be really great. Thank you!
I'm using the physics system, and working on a project which has a ragdoll. This is made of 10 instances of a 'body' object, and 1 instance of a 'head' object. These are created in an obj_ragdoll_create object. My code for this is here:
Code:
head = instance_create(x, y-48, obj_ragdoll_head);
body1 = instance_create(x, y-16, obj_ragdoll_body); //top of body
body2 = instance_create(x, y+16, obj_ragdoll_body); //bottom of body
physics_joint_revolute_create(body1, body2, x, y, 0, 0, 0, 0, 0, 0, 0);
physics_joint_revolute_create(body1, head, x, y-32, 0, 0, 0, 0, 0, 0, 1);
plus = 12;
leg1 = instance_create(x+plus, y+48, obj_ragdoll_body); //right leg
leg2 = instance_create(x+plus, y+80, obj_ragdoll_body); //far right leg
physics_joint_revolute_create(body2, leg1, x+plus, y+32, 0, 0, 0, 0, 0, 0, 0);
physics_joint_revolute_create(leg1, leg2, x+plus, y+64, -150, 150, 1, 0, 0, 0, 0);
leg1 = instance_create(x-plus, y+48, obj_ragdoll_body); //left leg
leg2 = instance_create(x-plus, y+80, obj_ragdoll_body); //far left leg
physics_joint_revolute_create(body2, leg1, x-plus, y+32, 0, 0, 0, 0, 0, 0, 0);
physics_joint_revolute_create(leg1, leg2, x-plus, y+64, -150, 150, 1, 0, 0, 0, 0);
arm1 = instance_create(x+plus, y-16, obj_ragdoll_body); //right arm
arm2 = instance_create(x+plus, y+16, obj_ragdoll_body); //bottom right arm
physics_joint_revolute_create(body1, arm1, x+plus, y-32, 0, 0, 0, 0, 0, 0, 0);
physics_joint_revolute_create(arm1, arm2, x+plus, y, -150, 150, 1, 0, 0, 0, 0);
arm1 = instance_create(x-plus, y-16, obj_ragdoll_body); //left arm
arm2 = instance_create(x-plus, y+16, obj_ragdoll_body); //bottom left arm
physics_joint_revolute_create(body1, arm1, x-plus, y-32, 0, 0, 0, 0, 0, 0, 0);
physics_joint_revolute_create(arm1, arm2, x-plus, y, -150, 150, 1, 0, 0, 0, 0);
instance_destroy();
When any part of the ragdoll collides with a 'hole' object, I want the entire ragdoll to be destroyed. The game involves catapulting ragdolls continuously towards this hole, so there will always be more than one in the room.
Simply calling with (obj_ragdoll_body) instance_destroy causes all instances to be destroyed. Destroying the parent upon collision also doesn't seem to work. I have also tried looping through instance_nearest using the repeat function, but this also doesn't seem to work. Any ragdolls which miss the hole are just meant to stack up nearby, without being destroyed, so these can sometimes be the nearest instances.
I'm quite stuck on this, as I don't just want the instances in collision to be destroyed, but all instances attached to it, without destroying the other ragdolls in the room.
Any help would be really great. Thank you!