I’m trying to create a tactical-turn-based-tile-game. I need to be able to check all the available points to where my character can move in a radius of 2 for exemple. I was thinking about using SphereCastAll to get all points around the unit doing the following:
But this doesn’t quite do what I expect it to do so I think I’m getting all wrong how SphereCast is used. What I except that is happening is a sphere that gets build around Character position in a radius of 2, but that’s not really what is happening. Does anyone have an idea what I could do to make this work?
Sorry if it isn’t so clear I’m not that good in english. Tell me if something isn’t clear.
var xNum = Mathf.Ceil(range / tileSizeX);
var yNum = Mathf.Ceil(range / tileSizeY);
List<Tile> availPoints = new List<Tile>();
for (var i = 1; i <= xNum; i++) {
availPoints.Add(allTiles.Get(playerTile.x + i, playerTile.y));
availPoints.Add(allTiles.Get(playerTile.x - i, playerTile.y));
}
for (var i = 1; i <= yNum; i++) {
availPoints.Add(allTiles.Get(playerTile.x, playerTile.y + i));
availPoints.Add(allTiles.Get(playerTile.x, playerTile.y - i));
}
In case you have hex tiles, algorithm will be somewhat different, but idea is the same.