Search Unity

Question Trouble with Ray Perception 3D

Discussion in 'ML-Agents' started by soundgarden134, Nov 23, 2021.

  1. soundgarden134

    soundgarden134

    Joined:
    Dec 27, 2019
    Posts:
    6
    Hello, I'm making an RL based ecosystem for my final career project and I'm having trouble using the Ray Perception Sensor, as it seems to be colliding with something on the left side of the agent. I thought it could've been colliding with itself, so I put the lion in its own layer called Lion and set the Ray Perception Sensor to ignore Lion layer, to no results. I also tried by adjusting both offsets, ray length, sphere cast radius and the only interesting changes that I get is that by lowering the sphere cast radius it goes from this:

    upload_2021-11-22_23-46-33.png

    To this

    upload_2021-11-22_23-46-49.png

    I made sure that all of the children components of the lion were in Lion layer aswell so I'm actually out of ideas. The ML Agents version that I'm using is 1.9.1.

    Thanks in advance.
     
  2. m4l4

    m4l4

    Joined:
    Jul 28, 2020
    Posts:
    81
    really weird behavior, the only time i had a problem like that was caused by an object held by the agent.
    Is there a reason why the start offset is lower than end offset?
    Do you get the same result by setting both vertical offsets to something like twice the height of the agent?
     
  3. soundgarden134

    soundgarden134

    Joined:
    Dec 27, 2019
    Posts:
    6
    Hi, thanks for answering.
    There's no particular reason, I was just trying tweaking every parameter to see if it changes anything, but it didn't help. I tried by using the max and minimum possible offsets and it didn't help either, so I ended up using just placeholder cubes as agents for now.
     
  4. WaxyMcRivers

    WaxyMcRivers

    Joined:
    May 9, 2016
    Posts:
    59
    I've experienced this when having prefab mode open while that same prefab is also open in my current scene. I think it's because the debug draw lines for the raycast are drawn through the editor and reference the scene and not the prefab mode. I wouldn't worry about it unless your rays are interacting the incorrect way while in the desired scene.
     
  5. JulesVerny

    JulesVerny

    Joined:
    Dec 21, 2015
    Posts:
    47
    As previous comment, are you debuging those Rays in Prefab Mode, or the actual gameplay ? (The background suggests your are in the Prefab Editor).
    I typically observe and check the Agent Rays, whilst running the Game/ Training, under Heuristic, to confirm tht my Rays are colliding with the things I expect. - Select Scene View, and then your Agent. To confirm behaviour. (Maybe an Additional Collider, or Object with a Collider is in the arena.)
     
  6. soundgarden134

    soundgarden134

    Joined:
    Dec 27, 2019
    Posts:
    6
    Hi, just to update:
    It was apparently an editor bug, and as you guys said, the raycast was drawn as if it was in the scene. I checked the rays in the actual gameplay and it was working properly. Thank you all
     
    WaxyMcRivers likes this.