Correct way to cast UInterface of Virtual functions? (NO UFUNCTIONS) C++

Posts 5 and 7 might help you

Can’t tell you how this behaves with no UFUNCTION macro since it might not be able to reflect without one. Normally you declare your functions as UFUNCTION in the IMyInterface.

I believe that the only time you use

Implements<UGrabInteractionInterface>()

is when you need to test a blueprint implementation, but I might be wrong. If a method is not UFUNCTION it can’t be implemented by a blueprint.

Another way is to cast to it

else if (const IGrabInteractionInterface* OtherInterface = Cast<IGrabInteractionInterface>(OtherOwner)) {
	bCanBeGrabbed = OtherInterface->CanBeGrabbed(InPrimitiveComponent);
}

My post 5 on that link gives some info on when and why, but Chatouille in post 7 says things might be different in current versions of the engine.

2 Likes