Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 25 Apr 2013
Offline Last Active May 29 2014 07:58 PM

Topics I've Started

Partitioning an A* 400x400 map every frame

03 May 2014 - 07:47 PM

Hi everyone,


So basically, in my game, im trying to maintain an even frame rate that is about 1/30 second for my 3D rts game.


I used this algorithm for my pathfinding - http://aigamedev.com/open/review/near-optimal-hierarchical-pathfinding/ .


So basically, I have this higher level map of 10 x 10 clusters of tiles with edge entrances that I use for the pathfinding.


When someone tells a unit to go somewhere, I need a quick way to see if the path is possible at all. So what I do is a flood-fill of the entrances of the 10 x 10 clusters every single frame, to partition the map entrances into global partitions. Then if a unit is commanded to go to a partition that its not already in, I already know that there will be no solution to the A* problem. This is a lot faster than doing a flood fill of the individual tiles of the map. However, the flood fill takes up 1/4 to 1/3 of my processing time each frame (I profiled it), resulting in the battle simulation being just barely fast enough for a small battle involving 60 - 80 active units while the rest of the units just stand there. Any more unit activity, and the frame rate gradually starts to degrade. This is also just for an AI player and a human player managing the two sides.


I've considered the following options to solve my quandary:


1. Dont flood fill and just wait for the A* search to fail, to see if a particular destination is unavailable. If people tell units to go to a place that is unavailable, the A* search will search the *ENTIRE* accessible map from that location, only to finally fail. That will be a slow search that I would expect to degrade the frame rate even more than it's already degraded. But, people can only click so fast, so - it might be better to just bite the bullet for one slow search when the player clicks every two seconds than to be flood-filling the map every 1/30th of a second.


2. Wait until the A* search searches a certain number of nodes, then pick the one with the smallest f cost and pretend it is the destination for now and just go in that path. The thing I can think of wrong with this is that if there is a really wide obstacle in the way (e.g. a wall or mazelike series of walls), the pathfinder will probably just get stuck on the wall. Otherwise, this would work ok.


3. Keep doing things the way I have been doing them. Works ok for 60-80 units in a battle (30 - 40) on each side. If i want larger maps appropriate for more than 2 players, the frame rate will be unplayable.


Also, my game has other scalability issues, but this is probably enough for one post. I'm definitely open to better ideas than the three I just mentioned!

2D Health Bars for Units in 3D Environment

17 February 2014 - 04:43 PM

Hi guys,


I am making a 3D RTS game with Direct3D. Basically, I want to make 2D health bars hovering over my units that show how many hitpoints they have left after receiving wounds. I'm not sure what a good way to go about this would be because the thing is, the health bars have to always face the camera, no matter what angle they are at from the center of the viewport. I also want them to look as close to perfectly rectangular as possible, but I want them to look smaller if they are farther away.


I don't want to post code, so I'm just looking for a "general concept" type of answer.



how to make In-Game command and control panel?

25 April 2013 - 01:13 PM

Hi all,


I'm programming the beginnings of an RTS game. Right now, I have a rudimentary 3D plane where units walk around on it and when they get within range, they shoot each other (without a shooting animation, but they have a walking animation). There are only units and walls for now.


Anyways, I thought it would be nice to have a 2D command and control panel on the bottom third or so of the screen. I'm using windows 7 and directx 9. I don't think this question requires me to show code because its more of a "general concept" question. I'm not sure what the general practices of posting code are but I would prefer to keep the code private for now, and just ask for a general answer.


Basically, I want to make a panel so when you select one or more units a bunch of command options come up, it has a little close up picture of the unit type and there is always a mini map in the right hand side of the control panel. Does anyone know of the general techniques people use to do this? Thanks!