bool GetUpdatedEquippedVelocities(Inventory.InventorySlot equippedSlot, out Vector3 velocityTarget, out Vector3 angularTarget)
        {
            bool realNumbers = false;


            Vector3    localPosition;
            Quaternion localRotation;

            TransformBehavior.GetValues(equippedSlot.item.equipTransform, equipID, out localPosition, out localRotation);

            Vector3 targetItemPosition = transform.TransformPoint(localPosition);

            Vector3 positionDelta = (targetItemPosition - equippedSlot.sceneItem.rigidbody.position);

            velocityTarget = (positionDelta * VelocityMagic * Time.deltaTime);

            if (float.IsNaN(velocityTarget.x) == false && float.IsInfinity(velocityTarget.x) == false)
            {
                realNumbers = true;
            }
            else
            {
                velocityTarget = Vector3.zero;
            }


            Quaternion targetItemRotation = transform.rotation * localRotation;

            Quaternion rotationDelta = targetItemRotation * Quaternion.Inverse(equippedSlot.sceneItem.transform.rotation);


            float   angle;
            Vector3 axis;

            rotationDelta.ToAngleAxis(out angle, out axis);

            if (angle > 180)
            {
                angle -= 360;
            }

            if (angle != 0 && float.IsNaN(axis.x) == false && float.IsInfinity(axis.x) == false)
            {
                angularTarget = angle * axis * AngularVelocityMagic * Time.deltaTime;

                realNumbers &= true;
            }
            else
            {
                angularTarget = Vector3.zero;
            }

            return(realNumbers);
        }
Beispiel #2
0
    public static void GetValues(TransformBehavior equipBehavior, int settingIndex, out Vector3 localPosition, out Quaternion localRotation)
    {
        localPosition = Vector3.zero;
        localRotation = Quaternion.identity;

        if (equipBehavior == null)
        {
            Debug.LogWarning("Cant get values... transform behavior is null");
            return;
        }

        equipBehavior.GetValues(settingIndex, out localPosition, out localRotation);
    }