Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        if (robotname == gameObject.name)
        {
            if (Input.GetMouseButtonDown(1))
            {
                Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit, 100, movementMask))
                {
                    motor.MoveToPoint(hit.point);

                    RemoveFocus();
                }
            }

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

                if (Physics.Raycast(ray, out hit, 100))
                {
                    Interactable interactable = hit.collider.GetComponent <Interactable>();
                    if (interactable != null)
                    {
                        SetFocus(interactable);
                    }
                }
            }
        }
    }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     if (selected)
     {
         if (Input.GetMouseButtonDown(0))
         {
             Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
             RaycastHit hit;
             Debug.Log("here");
             if (Physics.Raycast(ray, out hit))
             {
                 destination = hit.point;
                 Debug.Log("hit " + hit.collider.name + " " + destination);
                 if (hit.collider.name != GetComponent <Collider>().name)
                 {
                     motor.MoveToPoint(destination);
                     selected = false;
                 }
             }
         }
     }
 }