The Log in this code snippet gives out the correct value.
However, The Log in my Tick function accessing the same float variable keeps returning 0.0000.
Is this expected behaviour?
FYI: The value set in SetCameraYaw() is set via a bindAxis. Don’t know if this is relevant because if I hardcode the float variable to 2.f or something within the SetCameraYaw(), it remains 0 in the tick.
I think it’s definitely being garbage collected, to prevent that you have to add UPROPERTY() just above your variable. Like so:
private:
UPROPERTY()
float CameraRotationYaw;
There are also very handy things called specifiers in Unreal that you can put inside the parenthesis that will help you in the future more info here on specifiers
Garbage collection applies only to objects with a dynamic storage duration. float is a built-in type and allocates nothing at all, so how it can be GC’d?
Problem lies somewhere else.
What I’m thinking then is that it is getting reinitialized or reset somewhere else.
On the variable, write as a specifier VisibleAnywhere with that you can click on your actor when it’s already playing and you can check that variable in real time. Another thing you could try is using the specifier EditAnywhere and then you can change the value manually to see if it’s changing by itself on runtime.
My apologies guys for the late reply. I was on a holiday. @Vacui. It logs correct in the SetCameraYaw Function, but not in the Same tick function,
So I assume that would be the same object then? @barracius-AOne
Changing the properties did not help as well.