예제 #1
0
    //check for mouse input
    void Update()
    {
        RaycastHit hit;

        //on left mouse button down
        if (Input.GetMouseButtonDown(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            //the mouse ray has hit a collider in the scene
            if (Physics.Raycast(ray, out hit))
            {
                //reposition pointer object to the hit point
                pointerObj.transform.position = hit.point;

                //construct path:
                //starting at the current gameobject position
                //ending at the position of the pointer object
                path = PortalManager.GetPath(transform.position, pointerObj.transform.position);

                //stop existing movement routines
                StopAllCoroutines();
                //start new agent movement to the destination
                StartCoroutine(GoToDestination());
            }
        }
    }