Game crash when using AI inside level instances

Hi all.

I have a game which generates dungeons from streaming levels instances and then populates those levels with AI.

I have placed dummy versions of the AI characters inside the streaming levels which are destroyed and then replaced with the same AI but spawned on the server side only. (It is easier and more readable for me to level design this way).

However when I click play my game crashes whenever I attempt to create a level instance with AI on it. It does NOT crash with regular streaming levels without AI, nor does it crash when spawning an AI normally using a Spawn Actor From Class node. It seems that creating a level instance for each client with an AI character on the map causes the engine to crash…?

This didn’t happen to me in 4.27 – only once I updated my project to 5.2.

Any suggestions are GREATLY appreciated.

FYI, it spits the following error log when I click play:

Assertion failed: !ErrorDetected || GIsAutomationTesting [File:D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Misc\MTAccessDetector.h] [Line: 90] Acquiring a write access while there are ongoing read or write access
UnrealEditor_AIModule
UnrealEditor_AIModule
UnrealEditor_AIModule
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
kernel32
ntdll

I have isolated the cause of the problem: If an Actor with a Child Actor Component is contained inside a newly created Streaming Level Instance the editor will crash and spit the error above.

As a work-around, it seems that I can save a reference to the class inside the construction script and then destroy the component, then respawn it at begin play.

Another note: This issue didn’t occur in 4.27 – only once I updated my project to 5.2. Seems something went wrong during the update.

I have not tried reproducing this in a clean project.

–Jackson

Run into this issue just a few hours ago when upgraded from 5.1 to 5.2.

It looks like this issue is caused by “MTAccessDetector.h” which is introduced in 5.2. In release note:

  • Added multi-threaded access detector to delegates in order to detect concurrent access.

In my case, I don’t use any streaming level and oddly enough this crash only triggered when I killed one of the spawned AIs in the level. There are two, one zombie and one shooter. No crashed when the zombie is destroyed but as soon as the shooter AI is killed, it triggers the crash.

I thought this was something to do with destroying the child component (the weapon) in the shooter AI but it was not the case. After commenting out code block by block, it turns out that the culprit is the

virtual void Destroyed() override;

which I override to destroy the weapon when shooter AI is killed.

Removed this Destroyed() override and folded the destroy weapon code elsewhere fixed this crash for me.

Just my 2c. In case it helps someone else.

2 Likes

Anybody know why this is happening? I would really like to be able to parent my AI class because It would save on a lot of coding. As of right now, I have to have all AI using one AI class and behavior tree, which is not good when trying to make diversified AI.

1 Like

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