Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Fastest detection algorithm?

$
0
0
For a real-time strategy game, I use a grid to calculate collision. Units don't have a rigid body, they only occupy a cell of the physics grid and if a unit is trying to move on a cell that is occupied, a collision is triggered. The performance is pretty good. To detect if an enemy is close enough to do a melee attack, I use the same physics grid and I parse the 8 cells around a unit to find any enemies. The problem is that 8 cell scan per unit is too slow. The biggest bottleneck in my game is that units are constantly scanning the cells around them to detect enemies. This might not seem like a lot at a first glance, but it adds up really fast when this process is repeated tens of thousands of times. How can I improve my physical detection? Would running a rigid body simulation be faster than scanning cells?

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>