# Assert fails on EndPlay after an Actor was Spawned

**URL:** <https://forums.unrealengine.com/t/assert-fails-on-endplay-after-an-actor-was-spawned/1768342>\
**Category:** C++\
**Tags:** garbage-collector, spawn, spawn-actor, garbage-collection, unreal-engine, spawning-actors, CPP, Blueprint, question\
**Created:** [March 23, 2024, 2:04pm UTC](https://forums.unrealengine.com/t/assert-fails-on-endplay-after-an-actor-was-spawned/1768342 "2024-03-23T14:04:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSttuudd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SSttuudd](https://forums.unrealengine.com/u/SSttuudd)\
**Post date:** [March 23, 2024, 2:04pm UTC](https://forums.unrealengine.com/t/assert-fails-on-endplay-after-an-actor-was-spawned/1768342/1 "2024-03-23T14:04:04Z")

</div>

Hi

Despite all my efforts I fail to figure out how to fix this.  
After using SpawnActor (in cpp or in blueprint), if I stop the game, this check fails:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/0/b/c0b97f8b0f745ab20a769313b94a6d002f1a005f.png)

Ths actor is properly spawned with the correct class, I can see it in the level.  
What am I missing here?

Here is the callstack:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/7/1/8719b83367e906f13b36aacf23f22b6448116fe4.png)

And the code that spawns the actor:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/d/f/1dfdda3d1ea9f8c56a1643387ecce72242112fd7.png)

---

<div class="post-metadata">

**Author:** ![SSttuudd](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SSttuudd](https://forums.unrealengine.com/u/SSttuudd)\
**Post date:** [March 24, 2024, 12:56pm UTC](https://forums.unrealengine.com/t/assert-fails-on-endplay-after-an-actor-was-spawned/1768342/2 "2024-03-24T12:56:15Z")

</div>

The issue was on the actor itself. It was creating a component and incorrectly calling the “AddToRoot” function on it.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [April 23, 2024, 12:56pm UTC](https://forums.unrealengine.com/t/assert-fails-on-endplay-after-an-actor-was-spawned/1768342/3 "2024-04-23T12:56:59Z")

</div>

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