Moving objects in tile-based world

Started by
2 comments, last by Endurion 15 years, 3 months ago
Hi Im planning a rpg in a tilebased world. Ive done some pathfinding in tiles where each unit is always standing in exactely one tile. But in this game you can move "fluidly", like nudging (remember the map on old zelda games for example, or moing in "a link to the past") so you are between tiles. My problem is, how to restrict units and other objects to get into a tile that is non-walkable? I cannot do collision-check with each object against all surrounding tiles right? That would be slow. Is there a better method? Thanks a lot Erik
Advertisement
If non-walkable regions are always the entire size of a tile, then performing simple collision checking should work. The key is to use techniques that can quickly rule out whether or not collision checking is needed between certain objects given the current state.

I don't have time to elaborate right now, but one technique I've played with before are quad-trees, which can quickly identify if collision checking between objects is necessary. Try a search for those. There are other methods too, and I'm sure someone will post something. :-)

Hope this helps. Good luck.

EDIT: Actually, the regions don't have to be rectangular or anything. It just simplifies things when you actually determine that a collision check is necessary.
the tiles can be rectanglurar that no problem. I can check odd-objects (for example round) with some special routine (they are few).

But in very old games like A link to the past for super nintendo
http://wiimedia.ign.com/wii/image/article/782/782613/virtual-console-au-buyers-guide-part-4-20070423084933753.jpg

they manage quite fine. You guys think they do collision checks with all closeby tiles in such games?
Don't underestimate todays computers. If an object is moving you can check all the tiles it is going to cover, which amounts to maybe 5 or 6. That's nothing. The computers back then could handle that already.

You can cut the number of checks down if you only check the tiles you are about the enter exactly when you are entering them. Once you are in between tile borders you can always move (since you did check the tiles below already).

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement