Spawning a Character class

In my project I do this to spawn my character and works.

UWorld* const World = GetWorld();

		if (World)
		{
			FActorSpawnParameters SpawnParameters;
			SpawnParameters.Owner = this;
			SpawnParameters.Instigator = Instigator;

			// Spawn the new character based on number of pixels
			YourActorClass* NewActor = World->SpawnActor<YourActorClass>(Location, Rotation, SpawnParameters);
		}

Hey, I’m attempting to spawn a character class in to the game world for a player to posses later.

				ASpirit* mySphere = GetWorld()->SpawnActor<ASpirit>(ASpirit::StaticClass(), StartLocation, StartRotation,SpawnInfo);

it appears this isn’t working.

I also tried…

				ACharacter* tempDef = GetWorld()->SpawnActor<ACharacter>(Defender, StartLocation, StartRotation);

Defender is a uproperty that is ACharacter. The idea is for the C++ class to be converted into a blue print class.

nope, i get this error lol

This is weird. In my project the code works normally. Try this instead

World->SpawnActor<YourActorClass>(ActorClass, SpawnLocation, SpawnRotation);

and in the header file declare your ActorClass like this

TSubclassOf<class YourActorClass> ActorClass;