Search Unity

Change body colliders at runtime (Havok)

Discussion in 'Physics for ECS' started by gmentat, Nov 9, 2020.

  1. gmentat

    gmentat

    Joined:
    Nov 12, 2012
    Posts:
    15
    I want to destroy some of the colliders of a compound body. For example ones which collide with a chainsaw. What is the best way of doing it?

    I'm using Havok.
     
  2. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Regardless of which engine you are using, colliders are the same.

    To remove some of the instances of the compound collider, I suggest getting the CompoundCollider.Children array, creating a new array with only the ones you need and building a new CompoundCollider for them. I know it's not super efficient, but supporting a proper mutable compound collider is not easy and would have many implications on the default use case where it's immutable.
     
    gmentat likes this.
  3. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    Alternatively, rather the destroying some of the child colliders of the compound, you could just disable the collisions (set (ConvexCollider*)collider->Material.CollisionResponse = CollisionResponsePolicy.None) on the children.