# MonoGame - Left/Right Sided Collision Not Working

I'm working on a platformer as part of my course, the problem I have come across is Left/Right sided collision is not working very well. I already have bottom & top collision working. Here is an example of the problem in action:

As you can see pretty much all the time I'm slowing down, I know this issue but haven't found a work around code solution yet. The main problem I'm having as you can see is my player being able to slide almost into the middle of the block if he's coming down and moves into the block.

The slow down problem is due to my left/right collision code, I just haven't found a viable solution yet for sided collision.

Collision Code:

        foreach (SkyTile block in PlatformBlocks)
{

IntersectRectangle = block.GetRect();
GetRect().Intersects(ref IntersectRectangle, out IntersectResult);
if (GetRect().Intersects(block.GetRect()))
{
if (IntersectResult && (IntersectRectangle.Bottom > GetRect().Bottom))
{
isPlatformColliding = true;
}

if (IntersectResult && (IntersectRectangle.Top < GetRect().Top))
{
isPlatformBottomColliding = true;
}

if (IntersectResult && (IntersectRectangle.Left > GetRect().Left))
{
isPlatformLeftColliding = true;
}

if (IntersectResult && (IntersectRectangle.Right < GetRect().Right))
{
isPlatformRightColliding = true;
}
break;
}
}

if (isPlatformColliding)
{
velocity.Y = 0;
}

if (isPlatformBottomColliding && !isPlatformColliding)
{
velocity.Y = 20;
}

if (isPlatformLeftColliding)
{
velocity.X = 0;
}

if (isPlatformRightColliding)
{
velocity.X = -0;
}

• I think it should be IntersectRectangle.Left < GetRect().Left and IntersectRectangle.Right > GetRect().Right. You have it vice versa – dimitris93 Aug 15 '15 at 16:00