Can't use SpawnActor() inside custom function C++

Hello!
So, I have a custom class called AOrder and inside that class there’s a function SpawnOrder().
Inside that function I’m trying to call SpawnActor() for some other classes:

AOrder_Knight* Knight = GetWorld()->SpawnActor(start_position[0], start_rotation); //AOrder_Horseman* Horseman = GetWorld()->SpawnActor(start_position[0], start_rotation);

Inside PlayerPawn.cpp :

`void APlayerPawn::BeginPlay()
{
Super::BeginPlay();

    AOrder order;
    order.SpawnOrder();

}`

I’m getting an error “Change search path for PDB files”.

But when i put body of SpawnOrder() inside BeginPlay() it’s suddenly starts to work.
Any idea why something like this happens?
Thanks for any answer

EDIT:

Forgot to say:
I get error only when i start the game; compiler doesn’t complain about anything;
Error is “Cannot load UE4Editor-Core.pdb”

You need the templated version of SpawnActor.

	/** Templated version of SpawnActor that allows you to specify location and rotation in addition to class type via the template type */
	template< class T >
	T* SpawnActor( FVector const& Location, FRotator const& Rotation, const FActorSpawnParameters& SpawnParameters = FActorSpawnParameters() )
	{
		return CastChecked<T>(SpawnActor(T::StaticClass(), &Location, &Rotation, SpawnParameters),ECastCheckedType::NullAllowed);
	}

Your code should look like this:

AOrder_Knight* Knight = GetWorld()->SpawnActor<AOrder_Knight>(start_position[0], start_rotation); 
AOrder_Horseman* Horseman = GetWorld()->SpawnActor<AOrder_Horseman>(start_position[0], start_rotation);

Sorry, I have that in my code, but accidentaly removed it while pasting that into question.
Code is the same as your answer, but still doesn’t work.
Still when i’m trying to run that function in BeginPlay() i get an error, and when i just paste it’s body inside BeginPlay() suddenly starts to work.
I don’t understand xD

Ok, so i think i got the solution:
AOrder was a base class for AOrder_Knight, so when I included Knight into AOrder class, I ran into a circle dependency.

All i had to do was to create special actor (Order_Grid) and then just paste the code.