Search Unity

Feature Request ( Physics Shape ) Bool to prevent Child's collider being merged with parent's on Convert.

Discussion in 'Physics for ECS' started by Lapsapnow, Jul 18, 2022.

  1. Lapsapnow

    Lapsapnow

    Joined:
    Jul 4, 2019
    Posts:
    51
    I'm requesting a bool on PhysicsShape to prevent ECS entity colliders on children, being merged down into a composite collider on the parent during prefab conversion.

    The example:
    Body + Shield <<< Bullet

    I have a shield childed to a body ( in a gameobject prefab ), I want the shield to collide with incoming bullets and take damage to eventually be destroyed. Both it and the body can take damage from bullets. However, as the shield's collider is merged down into the parent's during conversion; the parent ends up taking the damage instead of the shield on collision with a bullet.

    I do not know how to prevent this merge.
    If there is already a way to prevent this, I can't find it anywhere - and it should be on the PhysicsShape anyway.

    Thank you greatly.
     
    Last edited: Jul 22, 2022
  2. scottjdaley

    scottjdaley

    Joined:
    Aug 1, 2013
    Posts:
    163
    Yeah this is quite annoying when you don't want it. For your specific use case, you could probably use the ColliderKey provided by a RaycastHit to determine the actual child entity that corresponds to that part of the compound collider.

    If you want to avoid the compound collider baking, you have to remove the parenting. I think it is possible to create a custom conversion system that unparents the child before physics conversion runs and then reparents at the end. Then you can simply add an authoring MonoBehaviour like "DontBakeCollider" to the child game object. However, this doesn't work when converting a prefab asset since unity doesn't let you change the parent of a game object inside of a prefab asset.

    There are several use cases where I want to have child colliders acting simply as triggers for raycasts. And in some of these use cases, I want to move the child colliders which means compound colliders with a ChildKey map aren't sufficient. I realize that there are some issues with PhysicsBodies and parenting, but I don't need PhysicsBodies on these trigger colliders. Setting the parent after conversion seems to work totally fine so this limitation is only from authoring.

    I agree that this should be an option on the PhysicsShape authoring component. Either the parent should have a way to not bake children, or the child should have a way to opt out of being baked into the parent. If there are certain combinations of components where this wouldn't work (such as having physics bodies on each), then simply add a warning or remove the option to disable the baking in these cases.
     
  3. Richay

    Richay

    Joined:
    Aug 5, 2013
    Posts:
    122
    This still seems to be the state with 1.2.0-pre.6. I need a collider on my netcode ghost for the DOTS character controller to function correctly, but I also want colliders on the limbs (which are animated). Unless there's some magic setting I missed somewhere, this means I need to find a probably hideous workaround.
     
    alemnunez likes this.