Search Unity

ML-AGENTS Raycast Bug?

Discussion in 'ML-Agents' started by James_Initus, Jun 24, 2020.

  1. James_Initus

    James_Initus

    Joined:
    May 26, 2015
    Posts:
    75
    Finished training a model from last night. It seemed to train well enough however there are some intermittent issues that I am seeing. In most cases, this doesn't happen but it happens often enough that it causes the agent to act "wrong".

    You see, the forward raycast sometimes goes through the block when it's close but it's not so close that the raycast start is inside the block, it's actually outside.


    This particular bot gets stuck, thinking it can move forward because the distance to the forward raycast is far enough. It basically just sits there doing nothing. The rest of the bots get there eventually.

    I've seen the raycast sometimes just start working and the bot turns and it goes on it's merry way...

    Any ideas what is happening here?

    Image: Bot is stuck attempting to move forward but since the raycast is through the block, it stops.
    Notice the other two veritcal ray casts also fire through the block.
    upload_2020-6-24_8-56-45.png
     
  2. mbaske

    mbaske

    Joined:
    Dec 31, 2017
    Posts:
    473
    I think RayPerceptionSensor uses SphereCasts, rather than RayCasts. So you'll need to consider the radius as well. Even if the ray origin is outside an obstacle, it might not detect it if that obstacle's nearest point is closer to the ray origin than the given radius.
     
    ervteng_unity likes this.
  3. James_Initus

    James_Initus

    Joined:
    May 26, 2015
    Posts:
    75
    I believe you are correct, I tried increasing the sphere mesh renderer on the AI object and lowered the sphere cast size by half, problem is gone I believe
     
    ervteng_unity likes this.