# Thread: Collision detection

1. ## Collision detection

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)

2. ## Re: Collision detection

Why don't you just make a 2 dimensional bit array. 0 is empty 1 is full.

Take the camera or object location and refer to the array to see if they collide.

or check out Dr. Kinesh Minoa's ICOLLIDE API.
Its free but you must ask him for it
Search: ICOLLIDE or collision detection

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•