示例#1
0
    private void FixedUpdate()
    {
        if (throwing && throwable != null)
        {
            Transform origin;
            if (trackedObj.origin != null)
            {
                origin = trackedObj.origin;
            }
            else
            {
                origin = trackedObj.transform.parent;
            }

            float slow = (float)Math.Pow(throwable.mass, 1.0 / 3.0);
            if (effect != null)
            {
                effect.Throw();
                effect = null;
            }

            if (origin != null)
            {
                throwable.velocity        = origin.TransformVector(Controller.velocity / slow);
                throwable.angularVelocity = origin.TransformVector(Controller.angularVelocity * rotateSpeed / slow);
            }
            else
            {
                throwable.velocity        = (Controller.velocity / slow);
                throwable.angularVelocity = (Controller.angularVelocity * rotateSpeed / slow);
            }

            throwable.maxAngularVelocity = throwable.velocity.magnitude;
        }
        throwing = false;
    }