Hi, I am making my own 2d engine to do similar things like openbor, but I am stuck on walls and platforms. Actually the word stuck is quite appropriate here, I have basic collision detection with rectangles and define these around obstacles, for wall collision I have used what is in the openbor to calculate the z plane left and right edges but not sure how to slide down.
So my my movement collision is like follows:
Right now the using the below example, how would I slide down the left and right edges if I was moving towards that edge i.e. if i press up against the edge i will get stuck?
____________________
/ /
left side / / . right side
/-------------------------/
Maybe someone can point me to the openbor code that deals with this? I didn't see anything any sliding against the left and right slopes?
So my my movement collision is like follows:
Code:
float dx = (velocity.x * delta);
float dz = (velocity.z * delta);
//This is general obstacle detection so basic rectangle shapes, no slopes on edges
boolean hasCollidedObstacleX = CM.collisionAt(this, dx, 0);
//Check static wall on vertical axis?
boolean hasCollidedWallX = CM.hitWall(100, 300, 100, 500, 1000, 600, 400, 5000, pos3d.x + dx, pos3d.z);
if (!hasCollidedObstacleX && !hasCollidedWallX) {
pos3d.x += dx;
}
//This is general obstacle detection so basic rectangle shapes, no slopes on edges
boolean hasCollidedObstacleZ = CM.collisionAt(this, 0, dz);
//Check static wall on horizontal axis?
boolean hasCollidedWallZ = CM.hitWall(100, 300, 100, 500, 1000, 600, 400, 5000, pos3d.x, pos3d.z + dz);
if (!hasCollidedObstacleZ && !hasCollidedWallZ) {
pos3d.z += dz;
}
Right now the using the below example, how would I slide down the left and right edges if I was moving towards that edge i.e. if i press up against the edge i will get stuck?
____________________
/ /
left side / / . right side
/-------------------------/
Maybe someone can point me to the openbor code that deals with this? I didn't see anything any sliding against the left and right slopes?