Scripting Optimization Question

Hey everyone, I have a question maybe y’all can help with.

*Ive currently got a grid based tactical game that spawns AI actors as attachments to each unit actor that requires AI

*The flow path is… the Unit actor (theres lots of these) waits its turn (float in seconds) and then calls an event that another blueprint sees (the combat system, which there is only one of) which tells the corresponding AI actor to use A-star pathfinding to decide where it should move on the grid (the grid is also its own blueprint)

*The issue is, once I reach about ~40 unit actors with attached AI doing this the game slows down.

My question is im sure theres a more performant way I can approach this, im pretty new to game development so im sure theres some way I could improve this. Let me know your thoughts!

P.S. I tried working this through with Behavior trees in unreal but because the grid is int index based and I cant blackboard those values it wasnt working out.

You seemed that you need to search about how to do profiling first. The reason could be visual resource, or some behavior of AIs. or It could be just the limit of blueprint, if you are using loop heavily. (c++ loop is faster than BP over hundred times.)