# FlatRedBall.Math.Geometry.AxisAlignedRectangle.LastMoveCollisionReposition

## Introduction

The LastMoveCollisionReposition is a property that exists for all Shapes. This property is set whenever a shape calls CollideAgainstBounce or CollideAgainstMove and the method test results in an actual collision. The LastMoveCollisionReposition property can then be tested to obtain information about collision.

## Code Example

When two AxisAlignedRectangles collide the collision side can be determined rather easily. The following code determines the side that two rectangles collided on:

Assuming rectangle1 and rectangle2 are valid AxisAlignedRectangles:

## Common Usage

### Platformers

The following code can be used in a platformer to detect if a character is on the ground.

Let’s look at the individual pieces of code above to see what is happening. The first line is:

This line of code tests to see if the character’s collision (which we assume is a circle) collides against the “LevelCollision” which can be any shape or an entire ShapeCollection. This method does the following:

• It adjusts the velocity of the calling object (the character in this case) so that it is no longer falling. This prevents gravity accumulation errors.
• It adjusts the calling shape’s (the character.Collision in this case) LastMoveCollisionReposition.
• It returns whether a collision has occurred.

So, as we can see, this first if-statement does *a lot*. Well, the most important thing initially is knowing *if* a collision has occurred. If it does, then we proceed to the body of the if-statement to find out if the player is actually on the ground.

The next line of code is:

This line of code tells us whether the collision that occurred should be treated as a ground collision. The reason this works is because “move” and “bounce” collision methods move the calling objects so they no longer overlap.