I am making a game with a lot of animated AI, somewhere around 500 active AI at a time. This works great so far.

My one issue is how much performance animating uses up. My issue is with culling, take the scenario below:

I have 20 units off screen that chop wood, if I cull comletely I cannot use animation events because they will not get triggered while culled, so I use cull transforms. I always prefer using animation events instead of using some timer in the code that calls ChopWood() at a set interval, I find it produces a lot of messy code.

I tried comparing performance between cull completely and cull transform and didnt notice any huge difference when using 200 agents.

So I am wondering if anyone has experience with this scenario and can warn me of any pitfalls I might encounter using animation events for this many agents. Will it end up killing my performance? Is it unreliable? If so, how did you solve it?

  • \$\begingroup\$ It sounds like you're already doing the best thing you can do: trying your options and measuring their performance. Is there anything we could tell you that would disprove the numbers you've measured for yourself? \$\endgroup\$ – DMGregory Sep 4 '20 at 11:30
  • \$\begingroup\$ @DMGregory Whenever I do something by my self and I cannot find anything online on the matter, and I think "Well there def should be a difference between these two settings, why am I not experiencing it?", I doubt my findings a bit and want some sort of confirmation. \$\endgroup\$ – Majs Sep 4 '20 at 13:02
  • \$\begingroup\$ Just to check: you've done this profiling in a published build, not inside the Editor in play mode? If so, it could simply be that updating the transforms is not the bottleneck in your scenario, and something else is contributing more heavily to your observed performance. \$\endgroup\$ – DMGregory Sep 4 '20 at 13:05
  • 1
    \$\begingroup\$ Profiling in the editor, even with the scene view closed, will not accurately reflect the performance of your released game. If the numbers you're getting look suspect, definitely repeat your test in a standalone build. \$\endgroup\$ – DMGregory Sep 4 '20 at 13:24
  • 1
    \$\begingroup\$ Sounds like you've found your answer independently then. Nice work! 🙂 Just keep in mind you should be measuring ms per frame, not FPS, when trying to evaluate performance costs. FPS is non-linear, so losing 5-10 means a different thing depending on whether you started at 200 or 60 or 30. \$\endgroup\$ – DMGregory Sep 4 '20 at 14:30

Your Answer

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

Browse other questions tagged or ask your own question.