UAbilityTask_SpawnActor::BeginSpawningActor assumes the incoming AActor*& SpawnedActor parameter is nullptr if no actor was spawned, but it does not initialize the parameter at the start of the function.
There are cases where SpawnedActor can retain stale data from a previous call, for example when the Spawn Actor ability task node is executed repeatedly inside a Blueprint loop. This can be problematic, as licensee mentioned, during World teardown, where ShouldBroadcastAbilityTaskDelegates() may return false and the spawning branch is not executed. In this case the function may return true while SpawnedActor still contains a stale pointer from a previous execution.
A straightforward fix would be to set SpawnedActor = nullptr at the start of BeginSpawningActor, similar to other ability tasks that spawn actors (e.g. UAbilityTask_VisualizeTargeting and UAbilityTask_WaitTargetData).
This does not appear to be a regression, as the implementation of AbilityTask_SpawnActor.cpp has remained largely unchanged since UE5 introduction. Behavior reproduced in UE 5.7 and UE5-Main CL 51575875.
1. Open the attached repro project.
2. Run the project in PIE with the debugger attached.
3. Place a breakpoint at the beginning of UAbilityTask_SpawnActor::BeginSpawningActor.
4. Start PIE, GA_TestSpawn ability will be activated and start calling SpawnActor task node inside a ForLoop.
5. Observe that on subsequent loop iterations the incoming SpawnedActor parameter is not nullptr and retains the reference to the actor spawned in the previous iteration.
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-369893 in the post.
| 0 |
| Component | UE - Foundation |
|---|---|
| Affects Versions | 5.5, 5.6, 5.7, 5.8 |
| Created | Mar 15, 2026 |
|---|---|
| Updated | Mar 16, 2026 |