# Collision Resolving

This topic is 2595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Silly me posted a topic in graphics programming by accident.
Okay so I'm working on a game in C# XNA and I'm having a hard time wrapping my head around a good collision resolve.

So here is the code I have so far for my AABB's
This will be run after collision has been confirmed

Vector3 Vec1, Vec2; //Intersection of the AABB's
Vector3 VecMin1, VecMax1, VecMin2, VecMax2; // Minimum of Box1, Maximum of Box 1, Minimum of Box 2, Maximum of Box 2 Respectively
bool X, Y, Z; //if X Y or Z are false then they will not be treated as moving
VecMin1 = Min + Position;
VecMax1 = Max + Position;
VecMin2 = Box.Min + Box.Position;
VecMax2 = Box.Max + Box.Position;
X = Y = Z = true;

if (Velocity.X > 0) { Vec1.X = Math.Max(VecMin2.X, VecMin1.X); Vec2.X = VecMax1.X; } else if (Velocity.X < 0) { Vec1.X = Math.Min(VecMax2.X, VecMax1.X); Vec2.X = VecMin1.X; } else { X = false; }
if (Velocity.Y > 0) { Vec1.Y = Math.Max(VecMin2.Y, VecMin1.Y); Vec2.Y = VecMax1.Y; } else if (Velocity.Y < 0) { Vec1.Y = Math.Min(VecMax2.Y, VecMax1.Y); Vec2.Y = VecMin1.Y; } else { Y = false; }
if (Velocity.Z > 0) { Vec1.Z = Math.Max(VecMin2.Z, VecMin1.Z); Vec2.Z = VecMax1.Z; } else if (Velocity.Z < 0) { Vec1.X = Math.Min(VecMax2.Z, VecMax1.Z); Vec2.Z = VecMin1.Z; } else { Z = false; }

My minimum need for collisions as well as the obvious are working slopes and wall sliding.
My intention for collisions are moving platforms, curves, slopes, actual physics like movement (EG moving so fast up a slope result in take off)
I've come up with theories but I can't settle on anything.
The world is made out of blocks 3 x 3 x 3 blocks. some are slope shaped (so their not quite blocks but you get the idea)
I want the resolve to work on a per collision basis. The only way I thought would work, I realized would overkill when colliding with multiple blocks.

Any and all help is appreciated,
Bombshell

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634088
• Total Posts
3015449
×