Example #1
0
    /// <summary> Called when a SenseGlove_Grabscript no longer wishes to interact with this grabable. </summary>
    /// <param name="grabScript"></param>
    /// <param name="fromExternal"></param>
    public override void EndInteraction(SenseGlove_GrabScript grabScript, bool fromExternal = false)
    {
        //SenseGlove_Debugger.Log("End Interaction, fromExternal = " + fromExternal);

        if (this.InteractingWith(grabScript) || fromExternal)
        {
            if (this.IsInteracting())
            {   //break every possible instance that could connect this interactable to the grabscript.
                this.pickupReference.parent = this.originalParent;

                this.BreakJoint();

                if (this.physicsBody != null)
                {
                    this.physicsBody.useGravity  = this.usedGravity;
                    this.physicsBody.isKinematic = this.wasKinematic;
                    if (grabScript != null)
                    {
                        this.physicsBody.velocity        = grabScript.GetVelocity();
                        this.physicsBody.angularVelocity = grabScript.GetAngularVelocity();
                    }
                }
            }

            this.OnReleased();

            this._grabScript   = null;
            this.grabReference = null;
        }
    }
Example #2
0
    public override void EndInteraction(SenseGlove_GrabScript grabScript)
    {
        if (InteractingWith(grabScript)) //only do the proper endInteraction if the EndInteraction comes from the script currently holding it.
        {
            if (this.originalParent != null)
            {
                this.transform.parent = this.originalParent;
            }
            if (grabScript != null)
            {
                //if we're not being held by this same grabscript a.k.a. we've been passed on to another one...

                if (this.physicsBody != null)
                {
                    this.physicsBody.useGravity  = this.usedGravity;
                    this.physicsBody.isKinematic = this.wasKinematic;
                    this.physicsBody.velocity    = grabScript.GetVelocity();
                    //this.physicsBody.angularVelocity = ???
                }
            }
            OnReleased();
            this.grabReference  = null;
            this._grabScript    = null;
            this.originalParent = null;
        }
    }
    /// <summary> Called when a SenseGlove_Grabscript no longer wishes to interact with this grabable. </summary>
    /// <param name="grabScript"></param>
    /// <param name="fromExternal"></param>
    protected override bool InteractionEnd(SenseGlove_GrabScript grabScript, bool fromExternal = false)
    {
        //SenseGlove_Debugger.Log("End Interaction, fromExternal = " + fromExternal);

        if (this.InteractingWith(grabScript) || fromExternal)
        {
            if (this.IsInteracting())
            {   //break every possible instance that could connect this interactable to the grabscript.
                if (this.pickupReference != null)
                {
                    if (pickupReference.transform.parent.name == "Molekül")
                    {
                        this.pickupReference.parent.parent = null;
                    }
                    else if (pickupReference.transform.parent.name == "editTeil")
                    {
                        this.pickupReference.parent.parent = GameObject.Find("Molekül").transform;
                        while (GameObject.Find("editTeil").transform.childCount > 0)
                        {
                            GameObject.Find("editTeil").transform.GetChild(GameObject.Find("editTeil").transform.childCount - 1).parent = GameObject.Find("Molekül").transform;
                        }
                    }
                    else
                    {
                        this.pickupReference.parent = this.originalParent;
                    }
                }


                this.BreakJoint();

                if (this.physicsBody != null)
                {
                    this.physicsBody.useGravity  = this.usedGravity;
                    this.physicsBody.isKinematic = this.wasKinematic;
                    if (grabScript != null)
                    {
                        this.physicsBody.velocity        = grabScript.GetVelocity();
                        this.physicsBody.angularVelocity = grabScript.GetAngularVelocity();
                    }
                }
            }

            this._grabScript   = null;
            this.grabReference = null;

            return(true);
        }
        return(false);
    }
 /// <summary> Ends the interaction between the grabscript and this hinge </summary>
 /// <param name="grabScript"></param>
 public override void EndInteraction(SenseGlove_GrabScript grabScript, bool fromExternal = false)
 {
     if (this.IsInteracting())
     {   //break every possible instance that could connect this interactable to the grabscript.
         if (this.physicsBody != null)
         {
             //SenseGlove_Debugger.Log("Re-Applied kinematics");
             this.physicsBody.useGravity  = this.usedGravity;
             this.physicsBody.isKinematic = this.wasKinematic;
             this.StopPhysicsBody();
             if (grabScript != null)
             {
                 this.physicsBody.velocity = grabScript.GetVelocity();
             }
         }
     }
     this._grabScript   = null;
     this.grabReference = null;
 }