Exemplo n.º 1
0
 /// <summary>
 /// If this object intersects its target zone, the transition to the next state is triggered.
 /// </summary>
 /// <param name="other">The collider of the intersected object</param>
 private void OnTriggerEnter(Collider other)
 {
     if (other.name == "TargetZoneStartTransition")
     {
         if (grab.EndInteractAllowed())
         {
             grab.EndInteraction(grab.GrabScript, true);
         }
         StateManager.Instance.GoToNextState();
     }
 }
    /// <summary> Add an object to this DropZone, and apply the desired settings. </summary>
    /// <param name="obj"></param>
    public void AddObject(SenseGlove_Grabable obj)
    {
        SenseGlove_Debugger.Log("Adding " + obj.name + " to the DropZone!");

        // remember original parent
        if (obj.IsGrabbed())
        {
            this.originalParent.Add(obj.GetOriginalParent());
        }
        else
        {
            this.originalParent.Add(obj.transform.parent);
        }

        bool[] props = null;

        if (this.snapToMe && (this.takeFromHand || !obj.IsGrabbed()))
        {
            obj.EndInteraction();
            Transform zoneParent = this.snapTarget;
            if (zoneParent == null)
            {
                zoneParent = this.gameObject.transform;
            }

            obj.gameObject.transform.parent        = zoneParent;
            obj.gameObject.transform.localPosition = Vector3.zero;
            obj.gameObject.transform.localRotation = Quaternion.identity;

            Rigidbody RB = obj.physicsBody;
            if (RB != null)
            {
                if (obj.IsGrabbed())
                {
                    props = obj.GetRBProps();
                }
                else
                {
                    props = new bool[2] {
                        RB.useGravity, RB.isKinematic
                    };
                }
                RB.useGravity  = false;
                RB.isKinematic = true;
            }
        }

        this.RBprops.Add(props);
        this.objectsInside.Add(obj);
        obj.SetInteractable(!this.disableInteration); //enable / disable interactions.
        this.OnObjectDetected(obj);
    }
Exemplo n.º 3
0
 /// <summary>
 /// If this object (aka Roboy's head) is pulled close enough,
 /// the transition to the HUD gets initiated and this object's position and orientation are resetted
 /// </summary>
 /// <param name="other">The other collider this object starts intersecting with</param>
 private void OnTriggerEnter(Collider other)
 {
     if (other.name == "TargetZoneStartTransition")
     {
         StateManager.Instance.GoToNextState();
         if (grab.EndInteractAllowed())
         {
             grab.EndInteraction(grab.GrabScript, true);
             this.transform.localPosition = defaultPos;
             this.transform.localRotation = defaultRot;
         }
     }
 }
    /// <summary> Called when an Object is detected and its event is called. End interation if needed, then snap it </summary>
    /// <param name="detectedObject"></param>
    protected override void CallObjectDetect(SenseGlove_Grabable detectedObject)
    {
        if (this.disablesInteraction)
        {
            detectedObject.SetInteractable(false);
        }

        if (this.takesFromHand)
        {
            detectedObject.EndInteraction();
        }

        if (!detectedObject.IsInteracting())
        {
            this.AttachObject(detectedObject);
        }
        else //we still are interacting, meaning we did not disable nor take from the hand.
        {
            detectedObject.InteractionEnded += Grabable_InteractionEnded; //not subscribed to untill this object is released.
        }
        base.CallObjectDetect(detectedObject);
    }