Game Development Community

EarlyOutObjectType work?

by rwillis · in Torque X 2D · 12/12/2008 (2:32 pm) · 3 replies

From what I've read, it looks like putting an object in the EarlyOutObjectType list of a scene object is supposed to make the scene object only collide with that object once, instead of multiple times. Is this correct? I tried to get this to work but it still collides multiple times. Has anyone else got this to work fine?

#1
12/13/2008 (5:08 pm)
I've never tried to use it, but I agree that looking at the implementation gives me the impression that it's supposed to quit checking for collision with the given type after the first hit.
#2
01/05/2009 (7:17 pm)
It's hairy but I got it to work.

EarlyOut seams to define IF an object will collide with another object. If early out returns true the objects will not collide.

The thing is that though the objects don't react as they would under normal collisions, it seams that "solve overlap" will still be active even thought the object isn't colliding.

here is some code I use for crates that collapse when players are knocked down on them or when hit with a flying crate (they do not collide with non moving crates or players who are not "knocked down"

public static bool TestEarlyOutFXPhysics(T2DSceneObject ourObject, T2DSceneObject theirObject)
        {
            FSMComponent _theirFSM = theirObject.Components.FindComponent<FSMComponent>();
            T2DCollisionComponent _ourCollision = ourObject.Components.FindComponent<T2DCollisionComponent>();
            T2DForceComponent _ourForce = ourObject.Components.FindComponent<T2DForceComponent>();
            effects.EffectPhysicsComponent _thisFXComp = ourObject.Components.FindComponent<effects.EffectPhysicsComponent>();
            if (_theirFSM != null && !_thisFXComp.Disabled && _thisFXComp.VerticalBreak && _theirFSM.Knockdown && theirObject.Physics.VelocityY > 600 ||
                _theirFSM != null && !_thisFXComp.Disabled && _thisFXComp.HorizontalBreak && _theirFSM.Knockdown && Math.Abs(theirObject.Physics.VelocityX) > 600)
            {
                _ourCollision.SolveOverlap = true;
                if (_ourForce.Count < 2)
                {                   
                    _ourForce.AddForce(_thisFXComp.Gravity);
                    _ourForce.AddForce(_thisFXComp.Drag);
                    _thisFXComp.Activate();
                }
                return false;               
            }
            else if (theirObject.TestObjectType(Game.Instance.ObjTypes.EffectPhysics))
            {
                _ourCollision.SolveOverlap = true;
                if (_ourForce.Count < 2)
                {                   
                    _ourForce.AddForce(_thisFXComp.Gravity);
                    _ourForce.AddForce(_thisFXComp.Drag);
                    _thisFXComp.Activate();
                }
                return false;
            }
            else
                return true;
        }
#3
01/05/2009 (7:54 pm)
Do you have to mark both objects earlyout to each other?