Example #1
0
    protected void UpdateInteracting()
    {
        var        ray = new Ray(transform.position, transform.forward);
        RaycastHit hit;

        Transform objectToInteractWith = null;

        if (Physics.Raycast(ray, out hit, raycastDistance, grabbedInteractableMask.value, QueryTriggerInteraction.Collide))
        {
//             Debug.Log("Hiting object to interact with");
            objectToInteractWith = hit.transform;

            if (InteractingObject.OnGrabbedHighlight(hit.transform))
            {
//                UpdateGrabbedHighlight(hit.transform);
                if (highlightedGrabbedObject)
                {
                    highlightedGrabbedObject.OffHighlight();
                }

                var highlight = hit.transform.GetComponent <HighlightManager>();
                if (highlight)
                {
                    highlightedGrabbedObject = highlight;
                    highlight.OnHighlight();
                }
            }
            else
            {
                if (highlightedGrabbedObject)
                {
                    highlightedGrabbedObject.OffHighlight();
                }
            }
        }
        else
        {
            if (highlightedGrabbedObject)
            {
                highlightedGrabbedObject.OffHighlight();
            }
        }

        InteractingObject.LogicUpdate();

        if (IsClickDown())
        {
//            interacting = false;
            interacting = !interactingObject.OffInteract(this, objectToInteractWith);

            if (!interacting)
            {
                if (highlightedGrabbedObject)
                {
                    highlightedGrabbedObject.OffHighlight();
                }
            }
        }
    }
Example #2
0
    protected void FixedUpdate()
    {
        anchor.localPosition = new Vector3(0, 0, anchorDistance);

        if (interacting)
        {
            InteractingObject.PhysicsUpdate();
        }
    }