masterpoi

12-31-2000, 04:49 AM

Hello,

I made a simple 3D world, based on 2D squares.

(Each square can have 4 walls, N, E, S or W)

To check if the viewer collides with one of the walls, i make the following steps:

-calculate the point the viewer is heading to (p2, p1 would be the viewers previous position)

-rico = (p2.y - p1.y) / (p2.x - p2.y)

-for each wall in a square

if (wall.orientation = north)

{

xt=((floor(p1.z)+0.15f)-p1.Z)/rico+p1.x;

if (p1.x < xt) && ( xt < p2.x) collision;

}

(for south, east and west the code is mush the same)

This does work in all cases except

-if you walk straight (angle = 0°) on to a wall (i can understand that (div/0))

-in a corner between two walls, you can walk through them

What am i doing wrong?

(If there are thing you want to know, i'll post the full code)

I made a simple 3D world, based on 2D squares.

(Each square can have 4 walls, N, E, S or W)

To check if the viewer collides with one of the walls, i make the following steps:

-calculate the point the viewer is heading to (p2, p1 would be the viewers previous position)

-rico = (p2.y - p1.y) / (p2.x - p2.y)

-for each wall in a square

if (wall.orientation = north)

{

xt=((floor(p1.z)+0.15f)-p1.Z)/rico+p1.x;

if (p1.x < xt) && ( xt < p2.x) collision;

}

(for south, east and west the code is mush the same)

This does work in all cases except

-if you walk straight (angle = 0°) on to a wall (i can understand that (div/0))

-in a corner between two walls, you can walk through them

What am i doing wrong?

(If there are thing you want to know, i'll post the full code)