3 ms·
It's hard to tell without seeing a screenshot or video of the game in question, but there are almost certainly ways to optimize this problem. If there are on t
by LarsDu88 3y ago
It's hard to tell without seeing a screenshot or video of the game in question, but there are almost certainly ways to optimize this problem.
If there are on the order of even several dozen enemies on the screen at any given time, you could simply maintain runtime sets of different factions and only do line-of-sight checks between hostile groups within a certain proximity.
There's probably hundreds of better ways to do this than by spamming raycasts.
I have a VR space game with dozens of spaceships, and there are generally never more than num_spaceships raycasts getting fired every frame
- hutzlibu 3y ago"but there are almost certainly ways to optimize this problem." Sure, I optimize what I can. But there is only so much I can do, without hurting the core game mechanic. Which is a arcade shooter, but also a hacker game, where you program your bots. So the bots are mostly limited to radar distance information by design, to work out their position in the world and what to do next (but to make this work with many bots, I already had to cheat a lot). And it is unreleased, in case you are wondering .. but I hope to ship an alpha, soon. So it already works and it is fun. So I won't change core functionality, but I am still optimizing wherever I can. 3 months ago, it would only run on gaming hardware. Now medium mobile phones (a big market) are within reach.
- JuanPosadas 3y ago> raycasts getting fired every frame Also don't need to do this every frame, do X% each tick (not frames literally), rotating which objects get their checks.