Esempio n. 1
0
    /*
     * public bool freePath (Vector3 p1, Vector3 p2) {
     *      Vector3 direction = (p2 - p1).normalized;
     *      float sight = (p2 - p1).magnitude;
     *      RaycastHit hit;
     *      return !rigidbody.SweepTest (direction, out hit, sight);
     * }
     */

    public ArrayList freePath(Vector3 p1, Vector3 p2, Vector3 forward)
    {
        ArrayList dubinPath;

        dubinPath = car.RSR(p1, forward, p2);
        draw.drawMultipleLines(dubinPath, Color.magenta);
        if (free(dubinPath))
        {
            return(dubinPath);
        }
        dubinPath = car.LSR(p1, forward, p2);
        draw.drawMultipleLines(dubinPath, Color.magenta);
        if (free(dubinPath))
        {
            return(dubinPath);
        }
        dubinPath = car.LSL(p1, forward, p2);
        draw.drawMultipleLines(dubinPath, Color.magenta);
        if (free(dubinPath))
        {
            return(dubinPath);
        }
        dubinPath = car.RSL(p1, forward, p2);
        draw.drawMultipleLines(dubinPath, Color.magenta);
        if (free(dubinPath))
        {
            return(dubinPath);
        }

        return(new ArrayList());
    }
Esempio n. 2
0
    public ArrayList freePath(Vector3 p1, Vector3 p2)
    {
        ArrayList dubinPath;

        dubinPath = car.RSR(transform.position, transform.forward, destination);
        draw.drawMultipleLines(path, Color.magenta);
        if (free(dubinPath))
        {
            return(dubinPath);
        }
        dubinPath = car.LSR(transform.position, transform.forward, destination);
        draw.drawMultipleLines(path, Color.magenta);
        if (free(dubinPath))
        {
            return(dubinPath);
        }
        dubinPath = car.LSL(transform.position, transform.forward, destination);
        draw.drawMultipleLines(path, Color.magenta);
        if (free(dubinPath))
        {
            return(dubinPath);
        }
        dubinPath = car.RSL(transform.position, transform.forward, destination);
        draw.drawMultipleLines(path, Color.magenta);
        if (free(dubinPath))
        {
            return(dubinPath);
        }

        return(new ArrayList());
    }
Esempio n. 3
0
    public ArrayList freeCarPath(Vector3 pos, Vector3 fwd, Vector3 dest)
    {
        ArrayList way;

        way = car.RSR(pos, fwd, dest);
        //Debug.Log (free (way) );
        //draw.drawMultipleLines(path, Color.magenta);
        if (free(way))
        {
            return(way);
        }
        way = car.LSR(pos, fwd, dest);
        //draw.drawMultipleLines(path, Color.magenta);
        if (free(way))
        {
            return(way);
        }
        way = car.LSL(pos, fwd, dest);
        //draw.drawMultipleLines(path, Color.magenta);
        if (free(way))
        {
            return(way);
        }
        way = car.RSL(pos, fwd, dest);
        //draw.drawMultipleLines(path, Color.magenta);
        if (free(way))
        {
            return(way);
        }

        return(new ArrayList());
    }
Esempio n. 4
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            destination   = DirectionUtility.getMouseDirection();
            destination.y = transform.position.y;
            calcPath      = true;
        }
        if (calcPath)
        {
            calcPath = false;
            go       = true;
            path     = car.RSR(transform.position, transform.forward, destination);
            draw.drawMultipleLines(path, Color.magenta);
            if (free(path))
            {
                return;
            }
            path = car.LSR(transform.position, transform.forward, destination);
            draw.drawMultipleLines(path, Color.magenta);
            if (free(path))
            {
                return;
            }
            path = car.LSL(transform.position, transform.forward, destination);
            draw.drawMultipleLines(path, Color.magenta);
            if (free(path))
            {
                return;
            }
            path = car.RSL(transform.position, transform.forward, destination);
            draw.drawMultipleLines(path, Color.magenta);
            if (free(path))
            {
                return;
            }

            go = false;
        }
        else if (go && path.Count > 0)
        {
            destination = (Vector3)path[path_index];

            float d = Vector3.Distance(transform.position, destination);
            if (d > 2)
            {
                Vector3 direction = (destination - transform.position).normalized;
                correctAngle(direction);
                DirectionUtility.makeKinematicMove(rigidbody, direction, speed);
            }
            else
            {
                rigidbody.velocity = Vector3.zero;
                transform.position = destination;
                path_index++;
                if (path_index == path.Count)
                {
                    go = false; path_index = 1;
                }
            }
        }
    }