Follow the first two recipes so that you have a UInterface
we can check for, and a class implementing the interface, which can be tested against.
Inside your Game Mode implementation, add the following code to the
BeginPlay
function:FTransformSpawnLocation; ASingleInterfaceActor* SpawnedActor = GetWorld()->SpawnActor<ASingleInterfaceActor> (ASingleInterfaceActor::StaticClass(), SpawnLocation); if (SpawnedActor->GetClass()->ImplementsInterface(UMyInterface::StaticClass())) { GEngine->AddOnScreenDebugMessage(-1, 1, FColor::Red, TEXT("Spawned actor implements interface!")); }
Given that we are referencing both
ASingleInterfaceActor
andIMyInterface
, we need to#include
bothMyInterface.h
andSingleInterfaceActor.h
in our Source file.