So I have been having trouble with detecting OnMouseDown() on the child object when parented to a rigidbody. I found out that rigidbodies make a combined collider with all it’s children so when clicking, it detects the empty game object and not the individual child objects. Is there a way to detect which child collider was hit when hitting the rigidbodies combined collider? Is there a way around this?
Ignore Raycast layer does not change anything and I have tried using a manual ray from screen etc.
I have tried
I need to have it setup this way so the parent rigidbody will be affected by physics whilst the children collide with the level and move altogether since they are children. I also need to do this inside 1 script.
Wait, so you’re saying that a RigidBody on a parent object yields OnMouseDown() events detected by the child even if the child doesn’t have a RigidBody? That sounds ludicrous. Or do both the parent and the child have a rigidbody? Why do they need to be parent/children in the first place?
I would imagine the OnCollision from the RigidBody would just detect the parent OR the child. But you’re saying they’re overlapping in space? Then it would only make sense that both of them are detecting collisions. If you want both to have rigid bodies but only one detect collisions, you could set one as a trigger (the one you don’t want to collide)–it will then only detect collisions but not act as physics, when a collider ENTERS it, if that makes sense.
Your description is a little ambiguous so if you could maybe explain with some code examples that might help.
So I have found a way to accomplish what I need, instead of parenting the children I just give them a fixed joint that is connected to the empty