I have 6 cubes parented to a “center” cube in the following mesh. The center cube is a rigid body with compound collision for its children, and the 6 outer cubes are static ghosts. The effect is that the entire object behaves as a single rigid body.
However, I would still like to have the outer cubes individually detect collisions. Unfortunately, they do not respond to sensor logic bricks since they are ghosts.
Is it possible to access the cont.sensors[‘mySensor’].positive value for the compound collision children?
Thanks
UPDATE:
I tried changing the children type to “sensor” and linking a spaghetti brick from the child’s sensor to the parent rigid body’s controller. That doesn’t seem to work either…
UPDATE 2:
No really satisfying solution, but see replies below for potential workarounds. Hopefully there will eventually be a BGE overhaul of parent-child relationships in a future Blender release.
Static objects can only detect objects set to Rigid Body or Dynamic. Sensor objects cannot detect other Sensor objects (from the brief testing I did, it doesn’t seem that they can detect Soft Bodies either).
Note that the Ghost setting doesn’t affect an object’s ability to detect collisions, so a Static object can still detect a Rigid Body or Dynamic object even if both are set to Ghost.
Another interesting thing to note is that for the compound collision setting to actually take effect, both the parent and child objects must have the Compound box checked. One effect of the Compound setting is that the child objects lose the ability to detect collisions regardless of their physics type. Any collisions they experience are instead detected by the parent object, and as far as I can tell, there isn’t a way to detect which child object the collision came from. The colliding object can’t tell which child object it hit either since all it will detect is the parent object.
Taking all this into account, the solution I would recommend would be to just make the parent and child cubes one object and parent separate sensor objects to it (without the Compound setting). Then just put the collision sensors on those. If you need to have more control over how the physics engine handles your object’s collisions in terms of movement, you can just use what you currently have with the addition of the non-compound sensor objects.
Thanks for the comprehensive and well-written answer. It’s not the one I would have liked but it’s the one I needed.
So I guess I’ll just create a “shell” around each of the outer cubes and parent non-compound sensors to each of those cubes. This will be slightly weird because I need to be able to scale the outer cubes in size so I’ll have to update the sensor “shells” at the same time.
Though I think it would be a good feature to retain the ability of child objects to detect collisions…
I think there was a post somewhere (maybe on BA) which summarizes all types of collisions. It was very handy, with all the types presented in a table or something, but I havent been able to find it again since the first time I saw it.
If anyone knows of it, a link would be great, would certainly help with these kinds of issues.
@AD-Edge - Was it this one that I made? If so, I was wrong about part of this, if I recall, and I completely omitted what Sensor objects can collide with. I should remake it.
EDIT: I believe sensors can detect static and dynamic objects, and dynamic objects can detect static, dynamic, and possibly soft-body and sensor objects.
Yeh that could be the one. Something like that to reference is very handy, so many combinations of collision possibilities, see people posting often about it.
Have you tried using a Python generated constraint? For my game I was using various combinations of compound options (with each having problems) until LaH gave me a Python constraint script that simulates joints. This is useful because there are no parent or child relationships (both objects are equal and are independent). Objects joined by this method can have independent collision hulls, movement, will register all rays etc, and sounds like what you want.
Demo attached. Just press P and watch each cube have its own collision event.
This system has its downsides, I can detail them later if you want.
I would love it in the future if the BGE had an overhaul of its parenting options. At the minute it has quite a number of bugs and odd behaviour.
Thanks Rubbernuke, that looks like a good solution to my problem, though it’s a lot of python code for something so simple… also it probably doesn’t scale well for many parent-child relationships, does it?
Since my model’s actions are pretty simple (elongating the outer boxes), I think I’ll just go with parenting a non-compounded “sensor shell” to each box.