Check if Actor implements an interface

How can I check if an Actor implements a specific blueprint interface? For example, I want to store a reference to an actor in a variable returned from an EventBeginOverlap, then call the interface functions in the other actor later on. But I need to first check if the actor given from the event implements the interface.

Thanks.

Use “Call Function/Utilities/Does Implement Interface”.

Best regards.

In Blueprints its save to call Interface Functions without checking first. But be aware that using any Outputs afterwards will default/null if it was a Object without Interface. In that case you want to check manually first before proceding.

Find from other site.
UKismetSystemLibrary::DoesImplementInterface( MyObject, UMyInterface::StaticClass() );

Simplest C++ method I’ve found for checking Interface implementation:

MyObject->GetClass()->ImplementsInterface(UMyCoolInterface::StaticClass())
6 Likes

UObject has an Implements() method, hence it can be simplified to

MyObject->Implements<UMyCoolInterface>();