Disclaimer I will look into behavior trees tomorrow, but I’m looking for some general suggestions on why the following blueprints are causing the framerate to drop so I can learn more about making efficient BPs.
What I’m trying to do
I have about 8 NPC’s in the scene (all instances of the same BasicAI class). They move around randomly but when the player looks at one of them, the others flock towards that instance. When the player looks away, they all return to random wandering.
Current situation
I actually have this behavior working inside the First Person Template, which I’ve added the attached BPs to. The problem is that the frame rate starts out around 80fps when I load the game, but then drops continuously to below 10fps after about a minute of playing.
Can you help me make this more efficient?
I’m wondering if there’s anything(s) in the BP’s that might obviously slow things down, but I’m also open to general suggestions on how other people would approach this goal (within BP’s). The first blueprint is the BasicAI Blueprint, the second is my modified FirstPersonCharacter BP file that comes with the template. I hope I’ve put enough commenting in the images to explain how I’m thinking about it, but if its not clear, I can explain further.
More info on my approach
The FirstPersonCharacter BP draws a trace looking out for any Pawns. If it hits one, it:
a) Sets this as the Pawn the others flock towards
b) Stops the pawns from roaming free (the pawnFreeRoam bool is set back to true if the Cast fails).
The BasicAI BP checks to see if pawnFreeRoam is true
-
if it is then the pawns are put into an array and each is moved to a random location IF they’ve reached the last random point (if velocity is <=0)
-
if pawnFreeRoam is false, the pawns are again put into an array and then move towards whichever instance is stored in the other BP’s pawnOfInterest variable.
Thanks in advance for any replies!