# Terrain type related problems in RTS game

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

## Recommended Posts

Hi,

I've started a small RTS project and had encountered some interesting problems for which I can't find solutions in the Internet and thus I've made my own algos for solving 'em but I'm not sure that I'm not inventing a wheel (and even that it's not a square wheel ).

Lets say we have a terrain built from a heightmap and with textures applied to it using splatting. There are 4 textures: sand, stone (red), grass, snow.

1. I want to allow construction of buildings only on terrain covered by stone. One of the approaches I can think of is to have a quadtree structure where sectors have boolean value saying if sector is constructible or not. The smallest size of quadtree's region is a size of smallest building's aabb. This boolean value in quadtree tree node is set according to color of region of pixels in splatting texture (if all pixels are red, mark this node as one in which building construction is allowed).

2. I have a vehicle and I want to change its speed according to terrain type (for example, on sand vehicle's speed should be reduced by 0.4, etc.). So I need to know on what terrain type vehicle is on. I thought of checking splatting map's pixel color in the current position of vehicle but I'm not sure this is a correct approach.

So guys I need your opinion, if described solutions are good or I'm inventing square wheel. Any help will be much appreciated.

##### Share on other sites
You can store the data inside your heightmap, use R and G channels for the height level, B for the construction data and the alpha channel for the speed factor.

Using this approach you will only need a short lookup function. Just remember to store the texture info inside the heightmap when you "paint" your terrain.

##### Share on other sites

Ok I think I've found solution to all my problems described in the first post. I should generate another grid not for geometry but for logic and store any info I want there (in tiles). I've read about this solution here: http://www.richardssoftware.net/2013/12/pathfinding-1-map-representation-and.html and I think it completely satisfies my needs.

You can store the data inside your heightmap, use R and G channels for the height level, B for the construction data and the alpha channel for the speed factor.

Using this approach you will only need a short lookup function. Just remember to store the texture info inside the heightmap when you "paint" your terrain.

Thank you for your answer but I think I'll stick to having additional grid for storing all required data. As far as I understand this is a common way to handle things in RTS games.

Edited by Shockwave

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 9
• 11
• 15
• 21
• 26