# SpawnActor failed because no class was specified 4.22

**URL:** <https://forums.unrealengine.com/t/spawnactor-failed-because-no-class-was-specified-4-22/454439>\
**Category:** Blueprint\
**Tags:** spawnactor, unreal-engine, question, Blueprint, CPP\
**Created:** [August 26, 2019, 9:14pm UTC](https://forums.unrealengine.com/t/spawnactor-failed-because-no-class-was-specified-4-22/454439 "2019-08-26T21:14:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveDM](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteveDM](https://forums.unrealengine.com/u/SteveDM)\
**Post date:** [August 26, 2019, 9:14pm UTC](https://forums.unrealengine.com/t/spawnactor-failed-because-no-class-was-specified-4-22/454439/1 "2019-08-26T21:14:03Z")

</div>

In attempting to create a C++ RTS game (loosely based on the brilliant 3ProngGaming’s blueprint only one on YouTube) and I’ve gotten completely stuck on it.

I’ve created two new classes. A ConstructionManager class and a Ghost Interactible Master Class with Blueprints for both and the 1x1 cube static mesh chosen.

In the header file:

```
// Construction Manager to Spawn at Begin Play
UPROPERTY(EditDefaultsOnly, Category = "Set Up")
TSubclassOf<class AConstructionManager> ConstructionManagerClass;

// Ghost building to Spawn at Begin Play
UPROPERTY(EditAnywhere, Category = "Set Up")
TSubclassOf<class AGhostInteractiblesMaster> GhostClass;

UFUNCTION(BlueprintCallable)
void SpawnConstruction();

UFUNCTION(BluePrintCallable)
void SpawnGhost();

```

And in the cpp file:

```
void AMyGameStateBase::SpawnConstruction()
{
	if (ConstructionManagerClass)
	{
		FVector Location(-400.f, -500.f, 235.f);
		FRotator Rotation(0.f, 0.f, 0.f);
		FActorSpawnParameters SpawnInfo;
		SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
		()->SpawnActor<AConstructionManager>(ConstructionManagerClass, Location, Rotation, SpawnInfo);
		UE_LOG(LogTemp, Warning, TEXT("Construction Manager Class Spawned at %s"), *Location.ToString());
	}
}

void AMyGameStateBase::SpawnGhost()
{
	if (GhostClass)
	{
		FVector Location(-400.f, 110.f, 235.f);
		FRotator Rotation(0.f, 0.f, 0.f);
		FActorSpawnParameters SpawnInfo;
		SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
		()->SpawnActor<AGhostInteractiblesMaster>(GhostClass, Location, Rotation, SpawnInfo);
		UE_LOG(LogTemp, Warning, TEXT("Ghost Class Spawned at %s"), *Location.ToString());
	}
}

```

In my Blueprint, I have the following:

![285911-classsetup.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/b/0ab0d3e6e328b0c7c6eb000ec6ea04db867c99b3.jpeg)

The problem is that while the Ghost class spawns fine, the Construction Manager does not.

The UE Log shows the following:  
LogBlueprintUserMessages: [ThirdPersonExampleMap\_C\_9] Spawning Character

LogBlueprintUserMessages: [ThirdPersonExampleMap\_C\_9] Spawning Construciton

LogSpawn: Warning: SpawnActor failed because no class was specified

LogTemp: Warning: Construction Manager Class Spawned at X=-400.000 Y=-500.000 Z=235.000

LogBlueprintUserMessages: [ThirdPersonExampleMap\_C\_9] Spawning Ghost

LogTemp: Warning: Ghost Class Spawned at X=-400.000 Y=110.000 Z=235.000

So the code to create the actor is being called with the correct class actually being specified in blueprint but for some reason, I’m getting a “SpawnActor failed because no class was specified” error message despite the fact that both pieces of code, apart from their names, are 100% identical.

Is there something I’m missing?

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [August 26, 2019, 10:28pm UTC](https://forums.unrealengine.com/t/spawnactor-failed-because-no-class-was-specified-4-22/454439/2 "2019-08-26T22:28:00Z")

</div>

Where do you call SpawnConstruction and SpawnGhost?

---

<div class="post-metadata">

**Author:** ![SteveDM](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteveDM](https://forums.unrealengine.com/u/SteveDM)\
**Post date:** [August 27, 2019, 9:19am UTC](https://forums.unrealengine.com/t/spawnactor-failed-because-no-class-was-specified-4-22/454439/3 "2019-08-27T09:19:38Z")

</div>

Currently, they’ve been made BlueprintCallable so are being called from the level blueprint when I press the F key but I will have them being called directly from the C++ BeginPlay when I can get it working.

---

<div class="post-metadata">

**Author:** ![Orfeas\_El](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Orfeas\_El](https://forums.unrealengine.com/u/Orfeas_El)\
**Post date:** [August 27, 2019, 1:45pm UTC](https://forums.unrealengine.com/t/spawnactor-failed-because-no-class-was-specified-4-22/454439/4 "2019-08-27T13:45:23Z")

</div>

Your workflow seems correct. Have you tried deleting your binaries & intermediate and rebuild the project?

Edit: On ()-\>SpawnActor(GhostClass, Location, Rotation, SpawnInfo);  
Try switching GhostClass to GhostClass-\>StaticClass()

---

<div class="post-metadata">

**Author:** ![SteveDM](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteveDM](https://forums.unrealengine.com/u/SteveDM)\
**Post date:** [September 2, 2019, 3:42pm UTC](https://forums.unrealengine.com/t/spawnactor-failed-because-no-class-was-specified-4-22/454439/5 "2019-09-02T15:42:59Z")

</div>

I’ve now tried deleting the folders and rebuilding, no change.

Interestingly, I moved everything to my Game State C++ files and without changing a line of code, it works perfectly but where I want (or at least the BP tutorial says to put) everything, the CameraPawn files, it doesn’t.
