I have a UFUNCTION that takes in a type of TScriptableInterface as one of its parameters. In the header, I have default values set for everything so when called in blueprint the function node has the defaults auto-filled. The compiler is throwing fits about object types not having a default value when the primitives do, so I want to set it to nullptr just to make it happy. This works for class types AActor actor = nullptr, but not for TScriptableInterface for some reason. Is there another null type I can set it to?
The LT and GT signs are somehow eaten up by this website, I originally wrote TScriptInterface<class IBuffableInterface> (hopefully shown now)
But if it is a smart pointer, forget about passing it as pointer as I suggested… It may be impossible to give it default value when used as UFUNCTION parameter. The UHT is not perfect yet. May someone correct me if I am wrong.
You can at least move the problematic paramter to the first position, so you can keep the default values for the other parameters.
Sorry that I can not help you further.
I tried TScriptInterface>class IBuffableInterface> *_owner. Compiler says inappropriate use of *, cannot have an exposed pointer to this type. And having a parameter with no default value as the first doesn’t work. Either everything has a default value or it doesn’t.
Hello, I’m using UE5.3…
so I had a similar issue with ‘double Tolerance = UE_DOUBLE_SMALL_NUMBER’.
the UE_DOUBLE_SMALL_NUMBER macro is defined as: (1.e-8), if I instead wrote my default parameter like: ‘double Tolerance = 1.e-8’ then it worked okay, so it seems the UHT didn’t like the brackets. Just find it strange that FMath has Tolerances that use this macro and it worked fine for Epic…
I guess in relation to the original question given this info, the UHT is like TScriptInterface is a different from nullptr since it doesn’t have the C++ knowhow to see that it’s a valid value. Hope this is of some good use, even if it doesn’t show a concrete solution to the original question.