Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                // move player to mouse click
                engine.MoveToPoint(hit.point);
                Debug.Log("We hit " + hit.collider.name + " " + hit.point);
                // stop focusing objects
                ClearTarget();
            }
        }
        if (Input.GetMouseButton(1))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                Interactable intertacble = hit.collider.GetComponent <Interactable>();
                if (intertacble != null)
                {
                    SetTarget(intertacble);
                }
            }
        }
    }