Here is my code, I’ve made sure that there is legitimate reference to VRPawn and all of these IAs work as expected, but the first two throw errors, the third doesn’t, the print statement works as expected, prints VRPawn_C without any error,
Is this behavior expected?
Its hard to tell form this context (also please next time upload more clear image).
Have you checked pawn that you are referencing is not destroyed somehow in that first call?
Or maybe just variable has been cleared out?
then Engine may have tried to traverse the blueprint paths on construction (they are supposed to only traverse the paths when the function/event is called, but JIT can be special at times. The good news is because blueprints are run through a sudo Virtual Machine it is “harder to crash”
if this VRPawn
is external to the class/blueprint (like if this is a controller) then for sanity, and to avoid crashes due to NULL_REFERENCE_EXCEPTION (which is a malloc fallback error) you should always check external pointers (blueprint references) for nullity before attempting to access them.
on each of these execution paths that do the first VRPawn->Get()
without calling your Set()
put in a IsValid()
the one with the question mark has the branch built in. I have a feeling if you put a different print on the failed
path of each of those at least one of them will be printed before the BeginPlay()
because Blueprints can be “weird”
Thank you for replying and sorry about the Image, here is clearer one
(Made changes and added validation to all inputs)
There is nothing that would indicate the pawn would be destroyed, and the function called in all 3 cases is the same function which is defined in the pawn and it executed like normal, there was just an error in the message log after the VRPreview,
The changes I’ve made work so this isn’t really a pressing issue anymore, but I still found it quite weird
Thanks.
I see. Well, if you want to get to bottom of this, maybe you can try to put breakpoints and catch the case when it complains.