No. because there is no longer any collision geometry in the physics system specifically identified with the colliders being composited. Indeed, compositing isn’t a lossless process because geometry specific to a collider can be lost or shared between multiple colliders.
So in summary, it’s not hitting a child collider, it’s hitting the composite which is the only active collider in the physics system. You can see this by rolling out the “Info” on the child colliders and note that there are no shapes generated, only on the composite.
Is it still possible to check for “ColliderB.OverlapPoint(Vector2 somepoint);”? (I’ve got to admit I don’t know a lot about how colliders work). Based on what needs to be checked and how, it could be a nice workaround. If this doesn’t work, what would happen instead?
As I just said, that information isn’t created so it cannot be queried either. Queries like OverlapPoint, Raycast etc perform an intersection test against the low-level physics objects i.e. circles, polygons, edges etc. The colliders used by a composite don’t create any low-level physics objects at all. Only the composite does.
The composite isn’t mean to be a representation of each of those colliders at runtime but a single collider that takes over for multiple colliders merging this geometry into one. Any individual collider details has been lost and isn’t able to be referenced or addressed via the geometry created by the composite.
Thanks for your answers!
I think i’ve solved by collecting every related gameobject and add it in List _allBricks;
This is how i decide which block is been hit :
_allBricks.OrderBy(x => Vector2.Distance(_collider.contacts[0].point, new Vector2(x.transform.position.x, x.transform.position.y))).FirstOrDefault();
xtoc,
this can be done more efficiently:
you don’t have to order - just to find the lowest distance.
Taking your example - it will look like this:
_allBricks.Min(x => Vector2.Distance(_collider.contacts[0].point, new Vector2(x.transform.position.x, x.transform.position.y)));