I am making Sniper game in unity 3d. In this game zombies will come randomly towards the sniper and sniper have to kill them. I am using RAIN(indie) for path finding. It works best when zombies are few . As I increase the Zombies( that is 10) the performance decrease a lot. The fbs drops to 25.

I want to know is there any technique or steps so I can improve fps Any other technique/algorithm that I can use for pathfinding weith good fps.


I already remove Sensor component from AI. FPS of game without AI is 61

  • \$\begingroup\$ What have you tried since posting this question? You should edit to include updates. \$\endgroup\$ – Seth Battin Aug 5 '13 at 5:01
  • \$\begingroup\$ @SethBattin As per suggestions I got, I used A* path finding technique but the FPS is still down. Then I used the Nav Mesh technique (unity pro) and FPS improved. So I decided to continue with Nav Mesh technique. \$\endgroup\$ – Zeeshan Mirza Aug 7 '13 at 5:39

The main technique is to simply not run the pathfinder every frame. Typically, you only need to run it once a second or less to get good results. Depending on what you're using it for, you may even just need to run it once ever.

Another common technique, when pathfinding for multiple units in different places to the same end location, is to instead search outwards from the end location to each of the units. This requires only a single pathfinding call for all the units, rather than one for each unit. This requires you to actually get down into the pathfinder-implementation, though; if your library does not already support this technique, there is no way for you to "fake" it, you'd have to switch libraries or write your own pathfinding code.

I can also second the recommendation for Aron Granberg's Unity pathfinding library; I've looked at his code and actually spoken with him personally, and I can vouch that the library is very well-optimized. I am not familiar at all with RAIN.

If you do decide to go the code-your-own-pathfinder route, I have written a priority queue optimized specifically for pathfinding that would be useful. I have not tested it with Mono/Unity, but I believe it should work fine.


I'm unfamiliar with RAIN, however using Aron's terrific A* pathfinding for Unity3d with dozens of units (on mobile devices) work like a charm:


P.S. RAIN might be as good as the package I've suggested or even better, it might be that you're just using it incorrectly.

  • 1
    \$\begingroup\$ -1 This isn't a which technology to use question. Please include suggestions for improving performance instead of just recommending a different library. \$\endgroup\$ – MichaelHouse Jul 31 '13 at 14:35
  • \$\begingroup\$ @Byte56 - Obviously since his question is so general it's nearly impossible to suggest how to improve suggestion - the 2nd part of my answer was "the answer" to his question \$\endgroup\$ – Ron Jul 31 '13 at 15:13
  • 1
    \$\begingroup\$ General improvements apply. For example, only finding the path once and the next time a unit spawns at that location, just use the same path. Only update paths every once in awhile. Increase pathfinding node size, therefore reducing node count. And so on. It's actually easier to answer in this generalized form. "it might be that you're just using it incorrectly" is a fairly poor suggestion for how to make it work better. \$\endgroup\$ – MichaelHouse Jul 31 '13 at 15:30
  • \$\begingroup\$ @Byte56 duly noted. \$\endgroup\$ – Ron Jul 31 '13 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.