Can you remove parent while in BGE?

Is there a way to remove the parent /child relationship if it was not created inside the BGE?. I know if you use the parenting actuator in the game engine it works. But if you use the edit object actuator to bring in a obj that is already parented to somthing else ( like a bunch of shards or loose objs that are all parented together) Can you end the parent in the game and then have the shards explode outwards. Is there a script that could accomplish this. It would be very usefull. Thanks

The breaking/shatter effect isn’t usually done in the way you mentioned. There are two easier methods to do this.

The first method adds the broken object into the scene when you need it. When you “break” an object, you replace the breakable object with the separated shattered version, you can do this easily using the add object and end object actuators.

The second requires a python script, depending on how you want to do it, you can have the shattered version of the object in the scene with the dynamics turned off. Every time you hit part of the object, you can turn the dynamics on for the object you hit. This gives you a kind of, “chipping” effect. Using this same method though, once you touch one shattered piece you can turn the dynamics on for all the shattered pieces. This gives you the same result as the previous method.

No need for parenting through layers. :stuck_out_tongue:

Collision(property “break”)--------------and--------------remove parent

Thanks for the help, i’ll try them out.

Thank Linkxgl, the first method,

“adds the broken object into the scene when you need it. When you “break” an object, you replace the breakable object with the separated shattered version, you can do this easily using the add object and end object actuators.”

seems to take a edit object/ add object for each piece of the shards created from the cell fracture. So in my space game I have a sphere that tracks to me and attacks. When it collides with a shot from my gun I have to do 20 add objects for each piece of the shards. If I could parent them all together first the use just one add object and then end parent it would have the same effect. but Ive trid that and it dosen’t seen to work.
Which brings me to Blueprint randoms reply of

“Collision(property “break”)--------------and--------------remove parent”.

If I make the parent in the game engine then it seems i can end the parent in the game. But I have to have all the shards in the game at all times. When the game starts I use the make parent, and when its hit use end parent. While this woks its a lots of extra objs in the game. 20 shards per ball times the number of ball i want to have attact adds up fast. If I parent the shards together in the 3d window and then try to end parent in the BGE it does not work.
So he best option would be to have the single solid ball in the scene attacking then when its hit, Add the shards all parented together so it only takes one add obj actuator, then end parent and watch them explode.
So I kind of back the the orginal question because I can’t find a way to make that happen. Thanks for the input but I’m still questioning.

Ahh. I thought it was just a few “shards”. You need to use python if you don’t want the process to be tedious. Even if you add the parent with its children (which works) when you unparent them the objects don’t retain their dynamics.

Do want an example? I made an example a while ago for 2.49b, I just have to touch it up for 2.6.

hrm, what about writting a python script to build the scene? I have not tried yet, but I think it is possible to assign the same logic for X pieces since they are all parented to the same empty?

select a “generic” cube with your parenting scheme, ctrl S to select a piece to set up, move a “generic” that has the parent on it with move to cursor , and then do join(while you make sure that you have all faces selected with the cube and none with the shard)
then tab and hit delete, to delete the cubes faces, leaving the logic :slight_smile:

this can be fast if you get good at it (I have had to replace complex systems before while keeping the mesh or vice verse)

so again, duplicate generic, snap to shard, join shard to cube, delete cube leaving logic

Ahaha, I think you’ll like this .blend a lot.

You need to make sure of a couple of things.
Every piece of the shattered object must have a common unique name. I’ll use the example in my .blend.
c_1,c_2,c_3, the common name is “c_”. If you have another breakable object you need to make sure that “c_” isn’t found anywhere in the object. So, a_1,a_2,a_3 would be fine for other parts of an object (this is what I meant with common unique).

On the object you’re going to break (but is “whole”), you need a property called “common_part_name” which holds a string of the common name of the shattered parts. In the case in my .blend, it was “c_”. So in the “common_part_name” property I’d put in “c_” (no quotes).

Basically, the script grabs every object with the common name in the inactive layers and adds them to the scene when you “break” the object.

Try it out! It’s cool because you can duplicate the broken parts in the inactive layer, and they will be added when you break the object, no need to edit anything. (:

break_test.blend (471 KB)

Use space to break the cube.

Thanks again i’ll try as soon as I have the time. Damn job keeps interfering with my blender time!

Thanks Linkxgl, That script works awsome. I copied the instructions from above into the text editor so I don’t forget them next time I try to use it. I can see lots of uses for this script. Every time you want spawn a lot of objects with just one actuator it should be great. If you follow the naming conventions.

And thanks BluePrintRandom for your idea. Unfortunity I can’t seem to get ti to work properly, any chance of getting a blend demo of the idea in action?

One more request if I can Linkxgl. It works perfectly on any object I create using the space key to break it. But, because I’m not a programer, I can’t make the script work with a collison sensor. Typicall I would have a bullet or missle with a unique property name hit the object and then it would break. This script looks like it only will work with a keybroard input. So i could it be modified to work with a collision sensor?
I really think this script could have universal appeal to everybody in BGE if we could use it with the other sensors. Thanks again.

Sure.

Now it works with any sensor at all.
break_test.blend (472 KB)

wow I can think fo a dozens uses for this. Thanks so much for your help.