Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Choosing which colliders will be visible for RayPerceptionSensor3D

Discussion in 'ML-Agents' started by Hsgngr, Jun 30, 2020.

  1. Hsgngr

    Hsgngr

    Joined:
    Dec 28, 2015
    Posts:
    61
    Hi fellows, I I have an agent who uses raycasts as observations. The problem is I would like to choose which collider should they hit and which collider they ignore.

    Here is an example where my agent (blue cube) colliding wth the other cubes sphere colliders which I am using for trigger.

    upload_2020-6-30_11-57-28.png

    These cubes have 2 colliders. One is for colliding with each other and the other is for triggering certain actions. How can I ignore this trigger sphere collider and hit directly the box collider ?

    upload_2020-6-30_12-0-55.png

    Wanted behaviour: (I closed the trigger collider)

    upload_2020-6-30_12-2-5.png
     
  2. Hsgngr

    Hsgngr

    Joined:
    Dec 28, 2015
    Posts:
    61
    I solved the problem by using Layers. I added a new layer for the agent prefab and only added this to the parent object. I took the cube collider and put that as a child. Then I changed only parent's layer. I closed IgnoreRaycast from Project Settings/Physics (InfectionLayer is the agent layer)

    upload_2020-6-30_17-26-58.png
    I unchecked the Ray Layer Mask > InfectiousLayer in RayPerceptionSensor3D
    upload_2020-6-30_17-28-19.png

    and voila. Now it hit as it should.