private void ThrowReleasedObject(Rigidbody objectRigidbody)
    {
        if (grabbedObjectScript)
        {
            var grabbingObject = grabbedObjectScript.GetGrabbingObject();
            if (grabbingObject)
            {
                var grabbingObjectScript = grabbingObject.GetComponent <VRTK_InteractGrab>();
                var controllerEvents     = grabbingObject.GetComponent <VRTK_ControllerEvents>();

                var grabbingObjectThrowMultiplier = grabbingObjectScript.throwMultiplier;

                var origin = VRTK_DeviceFinder.GetControllerOrigin(grabbingObject);

                var velocity        = (controllerEvents ? controllerEvents.GetVelocity() : Vector3.zero);
                var angularVelocity = (controllerEvents ? controllerEvents.GetAngularVelocity() : Vector3.zero);


                if (origin != null)
                {
                    objectRigidbody.velocity        = origin.TransformVector(velocity) * (grabbingObjectThrowMultiplier * throwMultiplier);
                    objectRigidbody.angularVelocity = origin.TransformDirection(angularVelocity * -1);
                }
                else
                {
                    objectRigidbody.velocity        = velocity * (grabbingObjectThrowMultiplier * throwMultiplier);
                    objectRigidbody.angularVelocity = angularVelocity * -1;
                }
            }
        }
    }
예제 #2
0
    protected override void ThrowReleasedObject(Rigidbody objectRigidbody)
    {
        if (grabbedObjectScript != null)
        {
            VRTK_ControllerReference controllerReference = VRTK_ControllerReference.GetControllerReference(grabbedObjectScript.GetGrabbingObject());
            if (VRTK_ControllerReference.IsValid(controllerReference) && controllerReference.scriptAlias != null)
            {
                VRTK_InteractGrab grabbingObjectScript = controllerReference.scriptAlias.GetComponent <VRTK_InteractGrab>();
                if (grabbingObjectScript != null)
                {
                    Transform origin = VRTK_DeviceFinder.GetControllerOrigin(controllerReference);

                    Vector3 velocity        = VRTK_DeviceFinder.GetControllerVelocity(controllerReference);
                    Vector3 angularVelocity = VRTK_DeviceFinder.GetControllerAngularVelocity(controllerReference);
                    float   grabbingObjectThrowMultiplier = grabbingObjectScript.throwMultiplier;

                    if (origin != null)
                    {
                        objectRigidbody.velocity        = origin.TransformVector(velocity) * (grabbingObjectThrowMultiplier * throwMultiplier);
                        objectRigidbody.angularVelocity = origin.TransformDirection(angularVelocity);

                        if (enemy != null && enemy.hitPoints > 0)
                        {
                            //enemy.OnOffCollider (true,false);
                            isThrow           = true;
                            rbGrab            = this.GetComponent <Rigidbody> ();
                            rbGrab.useGravity = true;
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        objectRigidbody.velocity        = velocity * (grabbingObjectThrowMultiplier * throwMultiplier);
                        objectRigidbody.angularVelocity = angularVelocity;
                    }

                    if (throwVelocityWithAttachDistance)
                    {
                        Collider rigidbodyCollider = objectRigidbody.GetComponentInChildren <Collider>();
                        if (rigidbodyCollider != null)
                        {
                            Vector3 collisionCenter = rigidbodyCollider.bounds.center;
                            objectRigidbody.velocity = objectRigidbody.GetPointVelocity(collisionCenter + (collisionCenter - transform.position));
                        }
                        else
                        {
                            objectRigidbody.velocity = objectRigidbody.GetPointVelocity(objectRigidbody.position + (objectRigidbody.position - transform.position));
                        }
                    }
                }
            }
        }
    }
예제 #3
0
    protected override void ThrowReleasedObject(Rigidbody objectRigidbody)
    {
        if (grabbedObjectScript != null)
        {
            VRTK_ControllerReference controllerReference = VRTK_ControllerReference.GetControllerReference(grabbedObjectScript.GetGrabbingObject());
            if (VRTK_ControllerReference.IsValid(controllerReference) && controllerReference.scriptAlias != null)
            {
                VRTK_InteractGrab grabbingObjectScript = controllerReference.scriptAlias.GetComponent <VRTK_InteractGrab>();
                if (grabbingObjectScript != null)
                {
                    Transform origin = VRTK_DeviceFinder.GetControllerOrigin(controllerReference);

                    Vector3 velocity        = VRTK_DeviceFinder.GetControllerVelocity(controllerReference);
                    Vector3 angularVelocity = VRTK_DeviceFinder.GetControllerAngularVelocity(controllerReference);
                    float   grabbingObjectThrowMultiplier = grabbingObjectScript.throwMultiplier;

                    if (origin != null)
                    {
                        objectRigidbody.velocity        = origin.TransformVector(velocity) * (grabbingObjectThrowMultiplier * throwMultiplier);
                        objectRigidbody.angularVelocity = origin.TransformDirection(angularVelocity);

                        if (weapon != null)
                        {
                            weapon.Thrown();
                        }
                        else
                        {
                            Debug.Log("NO SPEAR SCRIPT!");
                        }
                    }
                    else
                    {
                        objectRigidbody.velocity        = velocity * (grabbingObjectThrowMultiplier * throwMultiplier);
                        objectRigidbody.angularVelocity = angularVelocity;
                    }

                    if (throwVelocityWithAttachDistance)
                    {
                        Collider rigidbodyCollider = objectRigidbody.GetComponentInChildren <Collider>();
                        if (rigidbodyCollider != null)
                        {
                            Vector3 collisionCenter = rigidbodyCollider.bounds.center;
                            objectRigidbody.velocity = objectRigidbody.GetPointVelocity(collisionCenter + (collisionCenter - transform.position));
                        }
                        else
                        {
                            objectRigidbody.velocity = objectRigidbody.GetPointVelocity(objectRigidbody.position + (objectRigidbody.position - transform.position));
                        }
                    }
                }
            }
        }
    }
예제 #4
0
        private void ThrowReleasedObject(Rigidbody objectRigidbody)
        {
            if (grabbedObjectScript)
            {
                var grabbingObject = grabbedObjectScript.GetGrabbingObject();
                if (grabbingObject)
                {
                    var grabbingObjectScript = grabbingObject.GetComponent <VRTK_InteractGrab>();
                    var controllerEvents     = grabbingObject.GetComponent <VRTK_ControllerEvents>();

                    var grabbingObjectThrowMultiplier = grabbingObjectScript.throwMultiplier;

                    var origin = VRTK_DeviceFinder.GetControllerOrigin(grabbingObject);

                    var velocity        = (controllerEvents ? controllerEvents.GetVelocity() : Vector3.zero);
                    var angularVelocity = (controllerEvents ? controllerEvents.GetAngularVelocity() : Vector3.zero);

                    if (origin != null)
                    {
                        objectRigidbody.velocity        = origin.TransformVector(velocity) * (grabbingObjectThrowMultiplier * throwMultiplier);
                        objectRigidbody.angularVelocity = origin.TransformDirection(angularVelocity);
                    }
                    else
                    {
                        objectRigidbody.velocity        = velocity * (grabbingObjectThrowMultiplier * throwMultiplier);
                        objectRigidbody.angularVelocity = angularVelocity;
                    }

                    if (throwVelocityWithAttachDistance)
                    {
                        var rigidbodyCollider = objectRigidbody.GetComponentInChildren <Collider>();
                        if (rigidbodyCollider)
                        {
                            Vector3 collisionCenter = rigidbodyCollider.bounds.center;
                            objectRigidbody.velocity = objectRigidbody.GetPointVelocity(collisionCenter + (collisionCenter - transform.position));
                        }
                        else
                        {
                            objectRigidbody.velocity = objectRigidbody.GetPointVelocity(objectRigidbody.position + (objectRigidbody.position - transform.position));
                        }
                    }
                }
            }
        }
예제 #5
0
 // Token: 0x06001D4E RID: 7502 RVA: 0x00095E6C File Offset: 0x0009406C
 protected virtual void ThrowReleasedObject(Rigidbody objectRigidbody)
 {
     if (this.grabbedObjectScript != null)
     {
         VRTK_ControllerReference controllerReference = VRTK_ControllerReference.GetControllerReference(this.grabbedObjectScript.GetGrabbingObject());
         if (VRTK_ControllerReference.IsValid(controllerReference) && controllerReference.scriptAlias != null)
         {
             VRTK_InteractGrab component = controllerReference.scriptAlias.GetComponent <VRTK_InteractGrab>();
             if (component != null)
             {
                 Transform controllerOrigin          = VRTK_DeviceFinder.GetControllerOrigin(controllerReference);
                 Vector3   controllerVelocity        = VRTK_DeviceFinder.GetControllerVelocity(controllerReference);
                 Vector3   controllerAngularVelocity = VRTK_DeviceFinder.GetControllerAngularVelocity(controllerReference);
                 float     num = component.throwMultiplier;
                 if (controllerOrigin != null)
                 {
                     objectRigidbody.velocity        = controllerOrigin.TransformVector(controllerVelocity) * (num * this.throwMultiplier);
                     objectRigidbody.angularVelocity = controllerOrigin.TransformDirection(controllerAngularVelocity);
                 }
                 else
                 {
                     objectRigidbody.velocity        = controllerVelocity * (num * this.throwMultiplier);
                     objectRigidbody.angularVelocity = controllerAngularVelocity;
                 }
                 if (this.throwVelocityWithAttachDistance)
                 {
                     Collider componentInChildren = objectRigidbody.GetComponentInChildren <Collider>();
                     if (componentInChildren != null)
                     {
                         Vector3 center = componentInChildren.bounds.center;
                         objectRigidbody.velocity = objectRigidbody.GetPointVelocity(center + (center - base.transform.position));
                         return;
                     }
                     objectRigidbody.velocity = objectRigidbody.GetPointVelocity(objectRigidbody.position + (objectRigidbody.position - base.transform.position));
                 }
             }
         }
     }
 }