Пример #1
0
        private float getEffectiveWeightFromBody(Rigidbody body3D, Rigidbody2D body2D)
        {
            if (!body2D && !body3D)
            {
                return(0f);
            }
            Vector3 velocity          = body2D ? (Vector3)body2D.velocity : body3D.velocity;
            float   mass              = body2D ? body2D.mass : body3D.mass;
            bool    colliderIsNull    = body2D ? !body2D.GetComponent <Collider2D>() : !body3D.GetComponent <Collider>();
            bool    colliderIsTrigger = !colliderIsNull && (body2D ? body2D.GetComponent <Collider2D>().isTrigger : body3D.GetComponent <Collider>().isTrigger);

            if (FloatUtils.IsFirstFloatPreciselySmallerOrEqualToSecond(Mathf.Abs(velocity.y), 0.1f) && !colliderIsNull && !colliderIsTrigger)
            {
                return(mass);
            }
            return(0);
        }