Esempio n. 1
0
    public void FollowTarget(Interakcja newTarget)
    {
        agent.stoppingDistance = newTarget.radius * .8f;
        agent.updateRotation   = false;

        target = newTarget.interactionTransform;
    }
Esempio n. 2
0
    void RemoveFocus()
    {
        if (focus != null)
        {
            focus.OnDeFocused();
        }

        focus = null;
        motor.StopFollowingTarget();
    }
Esempio n. 3
0
    void SetFocus(Interakcja newFocus)
    {
        if (newFocus != focus)
        {
            if (focus != null)
            {
                focus.OnDeFocused();
            }

            motor.FollowTarget(newFocus);
            focus = newFocus;
        }


        newFocus.OnFocused(transform);
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }


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

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

                RemoveFocus();
            }
        }
        //Interakcja (PPM)
        if (Input.GetMouseButtonDown(1))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 100))
            {
                Interakcja interakcja = hit.collider.GetComponent <Interakcja>();

                if (interakcja != null)
                {
                    SetFocus(interakcja);
                }
            }
        }
    }