Rect2i.IntersectionDepth
Method
public Vector2 IntersectionDepth(Rect2i rect)
|
Parameters
Returns
Vector2
Intersection depth
DescriptionCalculates how far another rectangle intersects into this rectangle. The returned depth represents how much the rectangle would have to be offset so that it no longer collides. This method is useful in collision resolution. Examplevoid Update() { if (playerRect.Intersects(blockRect)) { var depth = playerRect.IntersectionDepth(blockRect); playerRect.x += (int)depth.x; playerRect.y += (int)depth.y; } } |
See AlsoRect2i.Intersect Rect2i.Intersects Rect2i.Contains |