Original Post
🔒 Locked
collision detection
Advertisement
Hi!
You could for example divide the world in a grid and let each cell in the grid remember what things that are in it. When you move something, you check if it collides with the contents of the new squares the thing will occupy, and in that case you take proper actions, e.g. prevents the thing from moving. Of course you''ll have to erase old cells which no longer are covered by the moving thing - it is actually quite tricky.
When you check whether the movable thing collides with the contents of a particular cell you could do an exact collision test between the movable and each thing in the cell. The easiest thing is probably to consider all things in your game to be made of spheres and to use a flat ground.
You could also use some more deliberate structure like a binary space partition tree (BSP tree), but then you''ll have to read about such datastructures on the internet.
A tutorial about collision detection (I didn''t like it very much but perhaps you do) is available at
Note:
You mentioned that you use Direct3D 9 - however, it does not matter what graphics engine you use since you''ll have to do everything yourself anyway.
Keen regards,
Magnus
You could for example divide the world in a grid and let each cell in the grid remember what things that are in it. When you move something, you check if it collides with the contents of the new squares the thing will occupy, and in that case you take proper actions, e.g. prevents the thing from moving. Of course you''ll have to erase old cells which no longer are covered by the moving thing - it is actually quite tricky.
When you check whether the movable thing collides with the contents of a particular cell you could do an exact collision test between the movable and each thing in the cell. The easiest thing is probably to consider all things in your game to be made of spheres and to use a flat ground.
You could also use some more deliberate structure like a binary space partition tree (BSP tree), but then you''ll have to read about such datastructures on the internet.
A tutorial about collision detection (I didn''t like it very much but perhaps you do) is available at
http://nehe.gamedev.net/lesson.asp?index=06
Note:
You mentioned that you use Direct3D 9 - however, it does not matter what graphics engine you use since you''ll have to do everything yourself anyway.
Keen regards,
Magnus
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement