Fix for Collision Broken after parenting?

Goodday to all!

I’ve been trying to solve this problem for more than three months but to no avail. Hope someone has a solution for this.

After setParent() to an empty, the object loss its ability to detect collision. Whether it is own.setParent(empty), own.setParent(empty, True, False), own.setParent(empty, False, True),
own.setParent(empty, False, False). Couple with any kind of physics types or collision bounds for the empty, with or without compound checked. Nothings works!

Is it broken? or i missed some crucial knowledge?

I sincerely thank for anyone who can help me with this!

I really want to know this too…its quite crucial for my project!

Same problem here. Here’s some examples where you can see the problem.

Edit: I found a workaround. Somehow there’s no but when the parent is Rigid Body.

Attachments

RemoveParent_Physics_update_bug_actuators.blend (87 KB)RemoveParent_Physics_update_bug_python.blend (87 KB)RemoveParent_Physics_update_bug_workaround.blend (87.4 KB)

Thanks Raco, glad that you spare some time to help!

I tested your workaround file but it didn’t work. I created an icosphere (with static physics and sphere collision bound) and located it within the scope of motion of the parented cube, the cube could not hit the icosphere.

Side question: Can we attach .blend file directly inside the post? If yes, what is the file size limit?

Thanks!

Go Advanced (bottom left) and click on the attachments button. The size limit is 2MB.

That’s only normal. Physics on parented objects are deactivated. So you would have to use Compound in order to update the Physics Mesh of the parent. It seems that by setting setParent() to Compound, there is also no bug with parent set to Dynamic. So this workaround works not only with Rigid Body, but also with Dynamic. See:

Attachments

RemoveParent_Physics_update_bug_workaround_2.blend (90 KB)

Just to be clear. The main issue in all the blends above is that the Motion actuator of the Parent object on rotation keeps affecting a child, even when it’s not a child anymore.

However, I realize now that the main question here has to do with Collision Bounds. I’m sorry for mixing that up. I guess I forgot about it when I was testing al possible scenarios. So just to be clear, I don’t think there’s an issue with Collision bounds (except for objects that are parented in the outliner which seem to lose their Physics properties and become Static after removing the parent).

Here is yet another test. Replacing the Motion actuator with Python applyRotation() will cause the child to be affected only temporarily.

I hope al these examples help developers to figure out what the real issue is.

Attachments

RemoveParent_Physics_update_bug_applyRotation.blend (87.8 KB)

You are brilliant Raco! Because of you i found out what is the the problems.

To explain,owner setParent()(python) to one object which is parented(in blender not python) to another object, in turn parented(in blender) to another object…confused?:spin::slight_smile: So in order for the owner to have collision detection, we need to set dynamic(or maybe rigid body) physics type to not the parent but the great grand parent with compound checked. The parent and grand parent can be no collision.

This solved my ages old confusion. You’d been so helpful and fantastic Raco! I owe you big one!:smiley:

However, my other problem is still persist because, unfortunately, the great grand parent is animated therefore the owner still cannot detect collision!:spin: Anyway, i’ll figure it out somehow.

Another big thanks for learning a lot of python from you(which you posted in many threads).
All the best!

@ love blender: I’m happy you found a solution to your problem. But I’m not sure if I can follow. If you want I can take a look if you post a blend with the exact situation you’re describing. It’s up to you.

Edit: With Static objects (grandparent, parent, child) there shouldn’t be any problems, as long as none of the children are parented in the Outliner (before the game starts). Except for the Motion rotation issue of course, you would have to use Dynamic objects to work around that. But that’s often not ideal.

Ok, so, if your using animated actions, and attempting to detect a collision,
I would use “Property based actions” and forward your property each logic step, and have a logic step spawn a invisable “hit object” rather then trying to re-calc a physics mesh… or have a parented object collide with it’s child (it can’t)

Wow! Good idea:eyebrowlift:, i’ve never thought of that. I’ll try give it a try. Thanks!

@Raco
For instance, I have a race track, with an object animated to follow the path. The owner will be parented to the object. Because the object is animated, no collision can be detected(as confirmed by BluePrintRandom).

What i mentioned in the previous post was that if we have an object parented many levels(child, parent, grandparent, great grand parent, great great grand…:D), the one need to be set to dynamic physics type is the great great … grand parent, otherwise it won’t work. I found out this because the objects in your file didn’t have animation and after trial and trial, parenting and parenting, i found out it worked. I wasn’t able to make it work since long time ago because my object is actually animated. Hope this clear you up!:slight_smile:

Thanks again buddy, great help!

PS. I think i need to search for an uploader to attach a file larger than 2mb.

Yes, it did.

@BluePrintRandom
It does work! Amazing! This open up a lot of possibilities, thanks again!

@Raco
Thanks for the link!

After further trials and errors, i found out there is a way to make this work(collision detection for a parented object to an animated parent). The solution is very unintuitive and under restricted scenario, which is the obstacle(the object to be collided) needs to be set to dynamic and the owner(the child) needs setParent(parent, False, False) instead of setParent(parent, True, False). I also found out that sometimes(no fix and logical circumstances) setting the obstacle to sensor did the trick, strange!

Attachments

demo_01.blend (559 KB)

It should always work with Sensor, Static, Rigid or Dynamic. In this case Sensor is all you need. You don’t even have to parent when the game is running. Do it in the outliner if that’s what you need. Collision on the child wouldn’t work with Compound, but you don’t need Compound anyway. You say that sometimes Sensor works. Are you speaking of this demo, or something else? Anyway, Sensor worked with me every time I ran the demo.

Hi Raco, glad you are here!

Do you mean you can get the collision working after changing the obstacle physics type to sensor in this demo?:eyebrowlift2: I could never get it to work. I’m using 2.67b. Do you mind confirming with me how you got it working?

If I set the child to Sensor it works with me. I’m using 2.67b too (64-bit).

I see. I thought you meant the obstacle. I want the child to be dynamic, unless we can temporarily change its physic type to sensor which i don’t think we can do that. Anyway, things are solved. Thanks!