Ejemplo n.º 1
0
    public void Grab(ObjectMover objectToGrab)
    {
        if (objectToGrab)
        {
            if (objectToGrab.GetGrabbed() && !objectToGrab.GetTwoHanded())
            {
                objectToGrab.GetGrabbedBy().Release();
            }

            objectToGrab.Grab(this);
            grabbedObject = objectToGrab;
            grabbedHighlighter.TurnHighlightOn(grabColor);
            //Debug.Log("Grabbing with controller: " + grabbedObject.name);
        }
        else
        {
            return;
        }
    }
Ejemplo n.º 2
0
    public void Activate(AttachmentTrigger trigger)
    {
        activated = true;

        if (trigger != null)
        {
            attachedObjectTrigger   = trigger;
            attachedObject          = trigger.GetOwningObject();
            attachedObjectMover     = attachedObject.GetObjectMover();
            attachedObjectGrabbedBy = attachedObjectMover.GetGrabbedBy();
        }

        if (attachedObject != null && attachedObjectMover && attachedObjectGrabbedBy)
        {
            attachedObject.SetBusy(true);
            inlineRot = GetLocalInlineRotation(attachedObjectMover.transform);
            attachedObjectGrabbedBy.Release();
            //attachedObjectMover.SetMoveMode(2);
            //attachedObjectGrabbedBy.Grab(attachedObjectMover);
            moveGuide.SetParent(this.transform);
            moveGuide.SetPositionAndRotation(attachedObjectTrigger.transform.position, attachedObjectTrigger.transform.rotation);
            attachedObject.KillCollision();
            attachedObject.KillPhysics();
            attachedObject.IgnoreCollision(owningObject.GetGameObject().GetComponent <BoxCollider>(), true);
            attachedObjectMover.transform.localRotation = inlineRot;
            //moveObjectOffeset = Vector3.Magnitude(attachedObjectMover.transform.position - attachedObjectGrabbedBy.transform.position);
            attachedObjectMover.transform.SetParent(moveGuide);

            //attachedObjectMover.transform.SetParent(moveGuide);
            tracking = true;
            owningObject.SetBusy(true);
        }
        else
        {
            Deactivate();
        }
    }