LeonBlade wrote:
And to make this post on topic, I've decided to make a height map for the game instead of using collision objects for every single object...
Basically it will make it so that I don't have to worry about my collision so much...
I will take an overhead view of my map and then based on the height of everything assosiate a lighter/darker color to the map...
And then for movement, anything that is to steep of an incline I will stop all velocity in that direction... oh crap... this doesn't sound fun lol...
Let me rethink this...
Yeah that's not a good idea at all...
I'm having some troubles with my collision lately... especially the physics and the ground collision stopping my player from falling through the map...
My current "map" is just a large plane and a few crates and a wall...
My collision is based on BoundingSpheres for the boxes and player model, and BoundingBoxes for things that are aligned to the grid with no angle applied...
Now, how in the world am I going to detect my player model against another object...
Both Box and Sphere have an intersect method that passes in another bounding object and returns a boolean value whether the collision is true or false...
Code: Select all
if (BoundingBox.Intersects(BoundingBox))
{
// Insert collision logic here
}
I'm not quite sure on what to do...
I could stop all velocity in the direction I'm facing... but I don't think that will work out so well...
I'm afraid the radius of the BoundingSphere is way larger than the actuall object, so I'll need to somehow show a visual representation of the sphere in order to figure out what I must do...
Do I check to see if each vertex of the object is touching the other object?
And to limit the amount of checking only check the colliding faces?
I'm pretty sure that is what I need to do... I just have to figure out how to do it...
I can get away without having to really working a lot on collision because all objects in the game will be rectangles essentially.
So if the left face of my player model is close enough with the wall face, then I want to stop any velocity I'm trying to get to the direction of the collision. I just don't know how to calculate that just yet, I don't have anything in front of me to mess around with.
I guess I could calculate the side I'm on depending on position of the player maybe?
Senario:
I strafe left.
The collision sphere of the player enters the collision box of the wall.
Collision logic begins.
All 4 vertices of the left face of my player model are within X ammount of distance from the wall vertices.
Checking positions.
Wall's X coordinate is 100
Player's X coordinate is 105
Stop all X velocity in the negative direction
Senario 2:
I'm moving into a corner.
The collisions meet and logic begins.
6 vertices are X ammount of distance from the two wall vertices
Checking positions
Left Wall's X is 100
Player's X is 106
Right Wall's Z is 60
Player's Z is 58
Stop all X velocity in the negative direction
Stop all Z velocity in the positive direction
Does that sound good?