# SpawnActor fails when run from the GameMode class

**URL:** <https://forums.unrealengine.com/t/spawnactor-fails-when-run-from-the-gamemode-class/1854493>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [May 13, 2024, 7:41pm UTC](https://forums.unrealengine.com/t/spawnactor-fails-when-run-from-the-gamemode-class/1854493 "2024-05-13T19:41:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![FBryant87](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FBryant87](https://forums.unrealengine.com/u/FBryant87)\
**Post date:** [May 13, 2024, 7:41pm UTC](https://forums.unrealengine.com/t/spawnactor-fails-when-run-from-the-gamemode-class/1854493/1 "2024-05-13T19:41:10Z")

</div>

I’m successfully spawning pawns using this code I have in one of my classes:

`GetWorld()->SpawnActor<ANpc>(NpcBlueprint, location, rotation, spawnInfo);`

This works as expected, and I can see Npcs appear when running my game.

But as soon as I move this code to the GameMode class (I need a class responsible for spawning NPCs), it fails with: _“SpawnActor failed because no class was specified”_

`NpcBlueprint` comes from a UPROPERTY, and this is definitely set correctly in the GameMode blueprint, in the exact same manner as the successful case.

For some reason it works fine in other classes, but when I put it in GameMode (either BeingPlay or even Tick), it simply doesn’t work. Is it something to do with blueprints from GameMode behaving differently?

---

<div class="post-metadata">

**Author:** ![Midisport\_8x8s](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Midisport\_8x8s](https://forums.unrealengine.com/u/Midisport_8x8s)\
**Post date:** [May 13, 2024, 8:54pm UTC](https://forums.unrealengine.com/t/spawnactor-fails-when-run-from-the-gamemode-class/1854493/2 "2024-05-13T20:54:28Z")

</div>

It’s probably something silly like you didn’t include a header or something.

---

<div class="post-metadata">

**Author:** ![FBryant87](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FBryant87](https://forums.unrealengine.com/u/FBryant87)\
**Post date:** [May 13, 2024, 9:25pm UTC](https://forums.unrealengine.com/t/spawnactor-fails-when-run-from-the-gamemode-class/1854493/3 "2024-05-13T21:25:58Z")

</div>

Hmm no way to get any more information than the console output? I’ve checked the headers and they match the successful case.
