Suppose I want to create an AI class in code that will be used to control a pawn, but I want my designers to be able to modify the behavior using blueprints for rapid iterations.
Suppose I have this in MyProjectBaseAI.h:
#pragma once
#include "EngineMinimal.h"
#include "GameFramework/Actor.h"
#include "MyProjectBaseAI.generated.h"
UCLASS()
class MYPROJECT_API AMyProjectBaseAI : AActor
{
GENERATED_BODY()
public:
AMyProjectBaseAI(const FObjectInitializer& ObjectInitializer);
virtual void BeginPlay() override;
virtual void Tick(float DeltaSeconds) override;
void SetGoalPosition(FVector pos);
virtual void DetermineGoalPosition(int32 stateData1, int32 stateData2) = 0;
private:
FVector goalPosition;
};
I would like to make this class abstract and have a blueprint able to implement DetermineGoalPosition(...);
to call SetGoalPosition(FVector pos)
depending on their design of the AI.
Then, how can the designers set the implementing class in the inspector so that my C++ code can instantiate it? Suppose I have a class that wants to instantiate the implementing class like this (currently using base class):
AMyProjectBaseAI* ai = World->SpawnActor<AMyProjectBaseAI>(...);