Nez.Portable/ECS/Components/Physics/Colliders/Collider.cs
/// <summary>
/// checks to see if this Collider with motion applied (delta movement vector) collides with any collider. If it does, true will be
/// returned and result will be populated with collision data. Motion will be set to the maximum distance the Collider can travel
/// before colliding.
/// </summary>
/// <returns><c>true</c>, if with was collidesed, <c>false</c> otherwise.</returns>
/// <param name="motion">Motion.</param>
/// <param name="result">Result.</param>
checks to see if this Collider with motion applied (delta movement vector) collides with any collider. If it does, true will be
returned and result will be populated with collision data. Motion will be set to the maximum distance the Collider can travel
before colliding.
checks to see if this Collider with motion applied ( delta movement vector ) collides with any collider . If it does true will be returned and result will be populated with collision data . Motion will be set to the maximum distance the Collider can travel before colliding .
public bool collidesWithAny(ref Vector2 motion, out CollisionResult result)
        {
            result = new CollisionResult();
            var colliderBounds = bounds;
            colliderBounds.x += motion.X;
            colliderBounds.y += motion.Y;
            var neighbors = Physics.boxcastBroadphaseExcludingSelf(this, ref colliderBounds, collidesWithLayers);
            var oldPosition = shape.position;
            shape.position += motion;
            var didCollide = false;
            foreach (var neighbor in neighbors)
            {
                if (neighbor.isTrigger)
                    continue;
                if (collidesWith(neighbor, out result))
                {
                    motion -= result.minimumTranslationVector;
                    shape.position -= result.minimumTranslationVector;
                    didCollide = true;
                }
            }
            shape.position = oldPosition;
            return didCollide;
        }
public bool collidesWithAny ( ref Vector2 motion , out CollisionResult result ) { result = new CollisionResult ( ) ; var colliderBounds = bounds ; colliderBounds . x += motion . X ; colliderBounds . y += motion . Y ; var neighbors = Physics . boxcastBroadphaseExcludingSelf ( this , ref colliderBounds , collidesWithLayers ) ; var oldPosition = shape . position ; shape . position += motion ; var didCollide = false ; foreach ( var neighbor in neighbors ) { if ( neighbor . isTrigger ) continue ; if ( collidesWith ( neighbor , out result ) ) { motion -= result . minimumTranslationVector ; shape . position -= result . minimumTranslationVector ; didCollide = true ; } } shape . position = oldPosition ; return didCollide ; }
checks to see if this Collider with motion applied (delta movement vector) collides with any collider.
checks to see if this Collider with motion applied ( delta movement vector ) collides with any collider .
// fetch anything that we might collide with at our new position // alter the shapes position so that it is in the place it would be after movement so we can check for overlaps // skip triggers // hit. back off our motion and our Shape.position // return the shapes position to where it was before the check
None
Vector2
ref
CollisionResult
out
motion
None
result
None