Ejemplo n.º 1
0
    private bool CheckPositionOnNavMesh(Vector3 loc, AI ai)
    {
        RAIN.Navigation.Pathfinding.RAINPath myPath = null;
        if (ai.Navigator.GetPathTo(loc, 10, true, out myPath))
        {
            return(true);
        }

        return(false);
    }
Ejemplo n.º 2
0
    private Vector3 GetPositionOnNavMesh(Vector3 loc, AI ai)
    {
        Vector3 avoidPoint;

        RAIN.Navigation.Pathfinding.RAINPath myPath = null;

        int tries = 0;

        do
        {
            avoidPoint = new Vector3(loc.x + Random.Range(-0.8f, 0.8f),
                                     loc.y,
                                     loc.z + Random.Range(-0.8f, 0.8f));

            tries++;

            if (tries >= 1000)
            {
                return(Vector3.zero);
            }
        } while(Vector3.Distance(loc, avoidPoint) > 1f && !ai.Navigator.GetPathTo(avoidPoint, 10, true, out myPath));

        return(avoidPoint);
    }