- Home /
RTS Grid and Pathfinding
I'm making an RTS game, but I don't know how to make a grid for building objects. How would I go about doing that?
Also, I really have no idea where to start on my AI pathfinding. I've seen something about A*; What is that?
I'm pretty new to Unity and only know some very, VERY basic crappy scripting (but I want to learn), so try not to use too much fancy lingo, and if you do, please explain it.
All help is appreciated!
Answer by Berenger · Feb 11, 2012 at 07:26 PM
If you're that new to Unity, pathfinding might be a bit of a stretch. A* is the name of the algorithm used for most path finding. I think it's about nodes, finding the closest neighboor etc. Anyway, if you still want to go for it, try AngryAnt or AronGranberg's packages.
About the grid, if you need only the visual part, projectors are great for that (see the unity package about projectors). If you need it for positionning stuff, that's another matter. There is some assets on the assetstore that could interest you, or you could do your own.
Actually, I looked into A-Star a bit more, and I think I might actually be able to manage that within time. The grid would be used in collaboration with the A-Star, so yes I do need it for positioning.
Answer by gamenut30111 · Sep 01, 2012 at 05:55 PM
I must agree with Berenger, A* pathfinding is quite a jump for someone new to unity, however to make a grid, here is a simple code :
var length : int;
var width : int;
var nodeSize : int;
var gridArray : new Array();
function Generate () {
for(var x = 0; x < width; x++){
for(var z = 0; z < length; z++){
gridArray.Add(Vector3(x*nodeSize, 0, z*nodeSize));
}
}
}
Your answer
Follow this Question
Related Questions
Grid system visualization 1 Answer
Best solution for Grid-based building system? 0 Answers
Pathfinding and AI for an RTS game 3 Answers
RTS dynamic formation width and length 0 Answers
How to write a basic pathfinding script 5 Answers