Nez.Collider.collidesWithAny C# (CSharp) Method

collidesWithAny() public method

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 collidesWithAny ( Vector2 &motion, CollisionResult &result ) : bool
motion Vector2 Motion.
result CollisionResult Result.
return bool
		public bool collidesWithAny( ref Vector2 motion, out CollisionResult result )
		{
			result = new CollisionResult();

			// fetch anything that we might collide with at our new position
			var colliderBounds = bounds;
			colliderBounds.x += motion.X;
			colliderBounds.y += motion.Y;
			var neighbors = Physics.boxcastBroadphaseExcludingSelf( this, ref colliderBounds, collidesWithLayers );

			// alter the shapes position so that it is in the place it would be after movement so we can check for overlaps
			var oldPosition = shape.position;
			shape.position += motion;

			var didCollide = false;
			foreach( var neighbor in neighbors )
			{
				// skip triggers
				if( neighbor.isTrigger )
					continue;

				if( collidesWith( neighbor, out result ) )
				{
					// hit. back off our motion and our Shape.position
					motion -= result.minimumTranslationVector;
					shape.position -= result.minimumTranslationVector;
					didCollide = true;
				}
			}

			// return the shapes position to where it was before the check
			shape.position = oldPosition;

			return didCollide;
		}

Same methods

Collider::collidesWithAny ( CollisionResult &result ) : bool