AI wont path for actors spawned after 45sec of play

I have a strange issue.

in my setup I have a moba-like map with 3 lanes and spawners at each end that send waves of AI-controlled characters down on a timer

When I run in the editor everything works as expected no issue

When I run from the editor Standalone … the 3rd wave sometimes 4th simply refuses to walk

Same happens in a build which is where I first noted the issue.

I have made sure its not my BT in that I have tried several different setups from a custom task, using AI Move To and using the out-of-the-box task

I have changed the values of the Crowed Managers max agents and cant figure out what the issue is

my units are not spawned in the floor, this issue doesn’t appear when I run in the editor at all I can leave it run for hours and its stable … but a build or even running from the editor but as a standalone will give this issue quickly

I don’t expect that there would be such a limit … and I would have expected a simple MOBA set up to be fairly commonly done in Unreal but I can not figure out what is going wrong made even more confusing in that I cannot get it to repeat when ran in editor.

I have also tried setting up print messages on the Move to call and they are not erroring or failing from what I can see its simply that the AI is refusing to navigate once a certain load is hit but only in a build

TL;DR
I have through testing determined that it is not due to the number of AI actors or navigation calls but seems to be bound to time.

45-55 seconds in no matter how few or many or how I spawn them at all
Navigation will stop pathing

PS: units that where moving before this time keep moving even after it and can aquire new targets, plot new paths, etc.
Only newly spawned units refuse to start walking

So now I am digging around to understand what happens about 45s to 60s in to the play
No its not networked this is playing singleplayer standalone that this does this.
Also this doesn’t do this when playing in editor window … only from a build or standalone process

Details of my crude testing so far.
Objective here is to understand why it stops, I see nothing in the stats or logs that suggests an issue at all. Paths are still being found the actors just don’t walk down them. The AI actors are still “thinking” that do target, attack, kill, die, etc.

They simply refuse to walk … no its not move speed, we do adjust that based on logic but I have confirmed its set to a non-zero value at all times.

Additional testing info in case it helps anyone point me at the cause of my issue

I have noted the 4th wav is always the wave where this happens and every member of this wave has this issue

so with my default settings, there are 19 AI actors in the world then each wave spawns 12 per team being 4 per lane so we have 91 spawned by the time the 4th wave starts

To test how this is affected by the number of AI actors I disabled 12 of my spawn on start actors … these 12 don’t path, they are AI but they are towers so no navigation just aim, shoot, etc. this means the same amount of navigation use, fewer AI actors

Resutls are the same, 4th wave refuses to walk, I know they do attack though, with the towers out of the way the survivors from the prior waves make it to our static units and get killed … so the AI is taking aim and attacking … just not able to walk

So my next test
This time I cut my wave size by half (2 instead of 4) this should get stuck on the 7th wave then … e.g. with 4 per wave the 3rd wave is the last good wave … so the 4th is stuck … with 2 per wave the same number of navigating actors will hit on the 6th wave.

Oddly … the 4th wave is still the wave that gets stuck
So its not the number of AI actors … its not the number of navigating actors is it time?

Lets test … back to 4 per wave and spawn waves twice as fast if its by time then wave 7 should get stuck

And that is what happened … so 6 waves walked on … the 7th did not
So it seems that somewhere between 60-70 seconds in navigation just buggers off … but why?

Lets check that once more and set our wave for 40 seconds … we will get 1 wave the second will not walk … we hope.

And yes that is what happens … so I can now check this by time and find at what game time does it stop exactly

To do that I will simply spawn 1 unit per second till it stops
44-55 seconds in

one suspicious place to check.

Print the return Boolean of ”run behavior tree” node.

see if it failed to run behavior tree.

make sure you don’t run behavior tree on controller’s begin play.run it on possessed instead.

the workflow is: controller begin play > on possessed > AI begin play.

if you run behavior tree before possessed,it sometimes fail to run it.

Thanks for the reply

I have traced a bit deeper

AI is definitely running … for example they will still target and kill each other

Turns out my initial ability effect is not being applied to new spawns after 45s or so

… so I am using the GAS tool and I set a units attributes by getting a “default” effect for each unit type basically this is just applying attribute overrides immediately so should set the walk speed to 275

and when I run in editor … it always does

When I run a standalone or build it does for the first 45sec no matter how many or how few I spawn

But for some reason after 45s every new spawn after that just doesn’t get its initial attributes set … digging in deeper to figure out why and then I need to chase down why 45sec

I have no timers or anything running and I have set up a dirt simple test level that has the same effect its always 45s

More testing has shown that my AttributeSet is not valid for any spawn after 45s of game play … why :person_shrugging: don’t know yet

AttributeSet = CreateDefaultSubobject<UUnitAttributeSet>(TEXT("AttributeSet"));

So I do this in
ALegendsCharacterBase::ALegendsCharacterBase(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer.SetDefaultSubobjectClass<UCharacterMovementComponent>(ACharacter::CharacterMovementComponentName))

Why it always works perfectly when playing in editor but not in a standalone or build is still confusing to me. It also doesn’t always fail in a build or standalone … it always works for the first 45s then never works after that … so what gives?

Okay ya I have to ask is Gameplay Ability System simply not fit for purpose?

I cant find any reason why the Attribute Set sub object should fail to be constructed and becuase it is the system is just a dead stick … I would have been better off rolling my own it seems

I’ll mark this as resolve as its not AI that is the issue but the Gameplay Ability System will resubmit a question if I dont just rip it out and replace it all together

my guess especially between editor and standalone is load order,

it could be that after 45s your computer is doing more and so it doesnt load a component quite as fast and then is Null.

another possibility is Garbage Collection.

I got around it by setting the base values in data
It was that after 45sec the approach I was using to create the AttributeSet was no longer creating the AttribtueSet so it was null

I set it in the actor’s Data and that seems to always work so something wonky with Unreal and working differently in Build vs Editor which I have learned is fairly common :slight_smile:

Just found and fixed another issue where … play in Editor works perfectly play in build or standalone … it does not

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.