Archived

This topic is now archived and is closed to further replies.

Cyril

Movement system for RTS game?

Recommended Posts

Cyril    122
Hi! I was thinking of a good movement system to implement for an RTS game (e.g. Starcraft, Warcraft, C&C, etc.) I am new to the industry (obviously), so the best idea I could come up with is as follows: - Separate the map into a grid of tiles - Tiles are only used for pathfinding e.g. (AStar) - Units can be positioned independently from Grid, and use the path generated by AStar to follow grid tiles, however with slight collision detection to make sure they don''t clash with other units. So pretty much, the only use for the grid in an/my RTS is for pathfinding and stationary obstacle avoidance, "fog of war", and stationary obstacle placement. The rest is pretty much simple movement with even simpler collision detection (e.g. distance between two points). The only thing I don''t know how to solve is the problem if variable unit size. Any suggestions? Improvements? Do you know a better way of doing this? Am I on the right path? Thanks for your time, - Cyril.

Share this post


Link to post
Share on other sites
Rasmadrak    196
Hello there!

I´m also developing a RTS game in the way you mentioned.
First of all; I think you should separate the tiles from the collision map/fog etc..

meaning...

_ _
|_|_| for every tile there´s four collision tiles.
|_|_|

And the variable size of units, why not simply check (using a for function or whatever you feel pleasant) if all collision tiles in the area the unit wants to go to is available?
^ this is how I've done it.

bool Collision(float/int sizex, sizey)
{
int Check = int Ok = 0;

for (sizex of unit)
{ for (sizey of unit)
{
if (CollisionMap[x][y].Available == true)
Check++;

Ok++;
}
}

if (Check == Ok)
return false;
else
return true;
}


Hope this helps!

[edited by - Rasmadrak on August 20, 2003 1:01:41 PM]

[edited by - Rasmadrak on August 20, 2003 1:02:27 PM]

Share this post


Link to post
Share on other sites