Why is the TScriptInterface<> Interface Pointer always 0x0000000

Ok, I assigned the IIItemFrame interface (C++) to my Blueprint User Widget but when I try to pass it to C++ class it always returns 0x000000 for the InterfacePointer.

I even cast it to check if it exists in the User Widget, which it does, but when I pass it to C++ object it is always null;

Here is my Blueprint

And this is the result in the C++

I just can’t seem to understand what is happening or what to do to pass the interface as data to be stored.

After a lot of testing and trying to make it work, I have finally made it work. I changed what is passed to ItemFrameData. Instead of:

TScriptableInterface<IIItemFrame> Interface

I changed it to

UObject* InterfaceObject

And, manually, casted the interface. Now, this also had some challenges but I have made it work like this:

While I do know that Unreal recommends this approach:

if (InterfaceObject && InterfaceObject->GetClass()
->ImplementsInterface(UIItemFrame::StaticClass()))
{
IIItemFrame::Execute_SomeFunction(InterfaceObject);
}

I just do not like this approach. I am very new in Unreal Engine (3-4 weeks) and I am probably wrong in doing it my way but it works. I understand there are no safety checks when using “reinterpret_cast” but it did copy the adress of the pointer to my Action.

The result is below:
image

I know it is “Error” but I am using Error parameter in UE_LOG because i can see it much clearer. It is for debugging only.

Hope this helps someone,
Cheers

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.