Search Unity

Physics2D.CircleCast strange behavior

Discussion in '2D' started by ciaravoh, Sep 23, 2017.

  1. ciaravoh

    ciaravoh

    Joined:
    Dec 16, 2009
    Posts:
    252
    Hello guys,

    I'm building a waypoint system to navigate from place to place. The network is built automatically in the editor using Physics2D.CircleCast. I circle through the list of waypoint and if I find one with a distance < 5, I add it to the list of nodes linked to the current waypoint.

    A strange thing is happening : when 2 waypoint are aligned the raycast if launch ver far above the limit of 5 units and a waypoint which is far from the current waypoint is added to the list. When I move it and it is no more aligned, it is not anymore casted...

    Code (CSharp):
    1. RaycastHit2D hit = Physics2D.CircleCast(cur.transform.position, 0.05f, (nextRoad.transform.position - cur.transform.position), 5f, nodeMask);
    2.  

    Any idea ?