Hi, the function pictured below has a local variable named Result. When the character overlaps an actor, the function sets the variable with the actor itself, but only if it does implement a particular interface, otherwise it is empty.
When I try to print the actor name inside the function, the behaviour is correct: if Result is setted with an actor it prints its name, otherwise it prints nothing.
The weird thing happens when I test the output outside of the function.
At start it prints nothing, but as soon the character overlaps an actor implementing the right interface, it continuosly prints the name of the last actor the character overlapped, even when there is no overlap at all.
It’s nothing fancy as you can see, only if there’s more than one overlapping actor it returns the one that the player is facing.
Here the Result variable is only setted once, but again it’s a local one, it is supposed to be empty every time the function is called (that is, every tick).
Anyway, I even tried to set it once at the beginning of the function with nothing at all, same result.
your print string is only on the true path, while i thought local variables reset too its still best practice to null them so just invalidate it on the false path
Thank you for your advice, setting up Result with an empty actor on the false paths seems to resolve the issue.
I guess that the local variable in blueprint has a peculiar behaviour.