Exemplo n.º 1
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && possessionCooldown <= 0 && !mouseOverSomeThing)
        {
            if (!allowToMove)
            {
                playerPos.StopPosses();
                allowToMove     = true;
                agent.isStopped = false;
            }
            else
            {
                RaycastHit hit;
                Vector3    mousePos = Input.mousePosition;
                mousePos = new Vector3(mousePos.x, playerHeigth, mousePos.z);
                if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, 100))
                {
                    agent.destination = hit.point;
                }
            }
        }

        if (possessionCooldown > 0)
        {
            possessionCooldown -= Time.deltaTime;
        }
    }