UPROPERTY array of objects implementing a specific interface

I have an interface that is implemented by several classes
It is used to mark some actors in my game as Service providers for player

class UServiceLocationInterface : public UInterface

class STARATLAS_API IServiceLocationInterface


	virtual const FText GetServiceName() = 0;
	virtual const FText GetServiceAdditionalInfo() = 0;

What I want to do is create something like this

TArray<TScriptInterface<IServiceLocationInterface>> ServiceLocations;

So that when I open the actor with this property I would be able to store a list of objects in my level that implement this interface

It is done in such a way because the services themselves are different actors and I want to be able to gather the information about nearby services in one place. The actor I want to store this in is actually a teleport point for the player. I want to be able to ask that teleport point which services does it have so the player has an easier time choosing where he wants to go

My current solution is

UPROPERTY(EditAnywhere, meta = (AllowedClasses = "TeleportPoint, Terminal"))
TArray<AActor*> ServiceLocations;

It properly shows only Actors I need in the editor and then when I get them from the list I cast them to my interface but it is not ideal


Interfaces aren’t instantiated (they’re abstract classes), so you can’t get an array of them from the world the way that you want to.

You can either get all actors in the scene, then add them to an array based on the success of the interface cast, or you can manually talk to the teleporter from the service provider actor on BeginPlay, and add a reference to the service provider that way.