Jump to content
  • Advertisement
Sign in to follow this  
Gallivan

Terrain Collision

This topic is 3524 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a list of units on the terrain (100 units or so). What I'd like to do is for each units "move turn" they should check if it's possible to move to that location. The only time it is impossible is if their final destination is an impassable terrain type. How should I store these terrain types? Should I store them as units and just test collision on them? This might end up in me iterating through both the Unit list and TerrainUnit list for every character... Are there any tutorials on how to perform terrain collision? I've searched for it but I mainly turned up results on collision detection (which I don't think is what I need...).

Share this post


Link to post
Share on other sites
Advertisement
Surely you just check the terrain of the tile (or polygon or whatever) that the unit would be on in the next frame using its current vector and if it is impassable then do not allow the move. Sounds like maybe a data-structure problem. Do you have efficient means to determine what tile is under a certain coordinate/position? If you do I can't see what the problem is. Each tile will know its own type, so you just check the type to see if it is impassable.
If you don't then you should create one (if the tiles are on a grid then it should simply be scaling the coordinate by a certain amount, and that will give you an index into the tile grid).

Share this post


Link to post
Share on other sites
Your wording is slightly confusing and perhaps lacking in details, how you do this will be down to the specifics:

- How is your data organised? Is your terrain a grid with each cell knowing whether it is passable or not, or is the terrain a large heightmap field with other ways of defining "impassable"
- If it is a grid, how many tiles can a unit move each "move turn", if its one then you will simply be checking whether that tile is "impassable", however if its more then one you are going to have to run a path finding algorithm to determine if a path to that position is possible and then act accordingly.

Alternatively, I have failed and read your question completly wrong :p

Scott

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!