Nez.Collider.overlaps C# (CSharp) Method

overlaps() public method

checks to see if this shape overlaps any other Colliders in the Physics system
public overlaps ( Collider other ) : bool
other Collider
return bool
		public bool overlaps( Collider other )
		{
			return shape.overlaps( other.shape );
		}

Usage Example

        /// <summary>
        /// moves the entity taking collisions into account
        /// </summary>
        /// <returns><c>true</c>, if move actor was newed, <c>false</c> otherwise.</returns>
        /// <param name="motion">Motion.</param>
        public bool move(Vector2 motion)
        {
            if (_collider == null)
            {
                return(false);
            }

            var didCollide = false;

            // fetch anything that we might collide with at our new position
            entity.transform.position += motion;

            // fetch anything that we might collide with us at our new position
            var neighbors = Physics.boxcastBroadphase(_collider.bounds, _collider.collidesWithLayers);

            foreach (var neighbor in neighbors)
            {
                if (_collider.overlaps(neighbor))
                {
                    didCollide = true;
                    notifyTriggerListeners(_collider, neighbor);
                }
            }

            return(didCollide);
        }