3dRaven
(3dRaven)
March 15, 2024, 9:07pm
2
Have ShooterCharacter implement an interface that has the function AddCoin. No need to cast in that case just check if the OtherActor implements the interface and call AddCoin on it.
Here is a good example:
I came across this topic when trying to solve a specific UInterface related issue and I thought I might add one important thing to the discussion.
There are actually 2 scenarios in which we’re calling UInterface functions in C++:
When interface is inherited by C++ class
When interface is added in the blueprint Class Settings
Each of those requires different handling in C++ when calling an interface function.
First scenario:
if (Cast<IInterface_MyInterface>(MyActor))
{
Cast<IInterface_MyIn…
Except you would have for example
Execute_AddCoin