Skip to main content
GameDev.net gamedev.net
🔒 Locked

Collision detection

Started by guyaton Sep 19, 2005 at 8:50 AM 5 replies 1.6k views
Original Post
guyaton
guyaton
how do you do collision detection in an isometric game, so that it doesn't look so blocky? I am using tiling in my game so far, but the problem is that with 32x32px tiles it looks horrible. do you assign distance values for the tiles? so that some you can move further towards the edge then others?? ~guyaton
~guyaton
streamer
streamer
collion between what? collision between static or movable objects?
Static object collision:
If object totaly occupie tile then player can't step on it.
partialy: if object partialy occupie tile, then check player coordinates, and look in which section of tile he is, and according to position allow player to step on tile section or not (this is for f.e 32x32 tile divided into 4 smaller tile 16x16, or smaller)
You can consider also to make layer that "show" where player can step and where not. Some pieces of that layer can have thicker grid some not. Imagine that layer like great bitmap that is clone of your level and on black pixels you can step on white not. It is not so memory consuming aproach because you will have lot of passable tiles, and resolving a whole problem with pointers will give you a great efficiency.
For movable objects like enemies just check for coordinate offset. Depending on AI of enemy he will get to close (and attack fe less than 30 pixels), or stay away (and use bow/magic/gun if fe. greater than 150 pixels)...

hope I helped you a little bit.
guyaton
guyaton
I was refering to static ground on a tile map. for example, lets say that one tile is a tree that is towards the left side of the image (lets assume that the inamge is 32x32 and the the tree is centered on ( 0, 15 ) and it extends 7pxs to the right, and 6px up and down). Is there an easy way to determine where the user can walk on this sqaure?

~guyaton
~guyaton
tonyg
tonyg
If the 'tree' fits in a tile then I would use the tile as collision rather than the tree. If the tree can be placed anyway (i.e. across tiles) then you might need to define a bounding box for the character and the tree and check those.
Another alternative is to use a different 'walkability' array than tiles (i.e. have 32*32 tiles but 8*8 walkability array). It will add time to your pathfinding but you could use a 2-tier approach by checking 32*32 for long distances and then 8*8 when close to the target.
http://www.policyalmanac.org/games/twoTiered.htm
Undeadlnsanity
Undeadlnsanity
I recommend you don't set the entire tile to a block state, but only parts of it. This will allow you to set tiny parts of a tile to the block state, so you can have things like winding paths which are actually followed by the player.
Liam M
Liam M
My engine uses 64x64 tiles, and each tile in the tileset has the option of having a "collision" object. This is simple a list of vertices on the tile which form a shape which "actors" (movingh things), have their collision rectangle (which can be a rectangle or any reasonable dimensions) tested against.
thewayout_is_through
thewayout_is_through
Everyone's already hit on similar ideas, but here's what I've done before.

First test to see if the whole tile collision takes place. Once you know some part of the tile collides you can have a bitmap/array for each tile which represents positions in the tile.

With a 32x32 pixel tile and 32x32 2 color bitmap for the tile, of which black=non-walkable and white=walkable, for checking the detailed collision against you have pixel perfect collision detection.
"Who are you, and how did you get in here?""I''m the locksmith, and I''m the locksmith."

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.