Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Compound Collider Questions

Discussion in 'Physics for ECS' started by TheGabelle, Nov 25, 2020.

  1. TheGabelle

    TheGabelle

    Joined:
    Aug 23, 2013
    Posts:
    242
    I am trying to implement a runtime 3D cursor (think transform gizmo). My idea is to create a single Entity with a 3DCursor ICD tag with a compound physics collider where boxes represent the three axis.
    1. When resolving a raycast, can I determine which of the primitives that comprise the compound collider was hit so I can determine which axis is being dragged?
    2. Looking at the compound collider example, why are lines 55 and 56 necessary? I assume line 58 or 59 would apply the same logic.
     
  2. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    1. You get a collider key in the RaycastHit structure, you can use that to get the child from the compound collider which was hit. CompoundCollider.GetChild(ColliderKey, out child) is the thing you need to call.
    2. Those 2 lines are there for our own collection of the stuff we created, to be able to dispose them later in the base class. Nothing to worry about in your code.
     
    TheGabelle likes this.