ACodeTSSGameMode::ACodeTSSGameMode(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
// set default pawn class to our character class
DefaultPawnClass = ACodeTSSPawn::StaticClass();
AEnemy Enemy = AEnemy(ObjectInitializer);
}
This is what I am trying to do basically.
I created an Enemy class with a Target property of type APawn. I want to instantiate the Enemy class, set the Target to the player’s pawn, and then spawn the Enemy. Here is basically what I want:
//create an enemy instance
AEnemy Enemy = AEnemy(ObjectInitializer);
UWorld* const World = GetWorld();
if (World)
{
//set the target pawn
Enemy.SetTarget("Somehow get player pawn here");
//spawn the instantiated enemy
World->SpawnActor<AEnemy>(Enemy::StaticClass());
}
Sorry for any poor formatting.
I’m not used to C++ yet, so thats another barrier. I think I might need to look up a quick refresher course.