I’m currently experimenting with 5.7’s MVVM, and I’m trying to bind to a Field Notify function. The docs say this should work, if my func is pure and const, which it is, and the Field Notify variable that references it also has the function set. I can see that my variable is actually decreasing in value like it should be, as per the timer calls, but for some reason it’s only broadcasting to the Field Notify function once, at the very start, but then never again.
I’ve attached screenshots of my setup. In the GM_TargetGame you can see where my timer event calls “Update Time Left”. This is confirmed by adding prints - it really does call it every second, properly.
In the VM_GameHUD you can see the UpdateTimeLeft function. It decrements the time left, and then sets it on the Time Left variable with the Field Notify broadcast. This triggers the GetTimeLeft function to fire once, but beyond that, it never fires again.
After many wasted hours, I figured it out. Apparently it’s not compatible with the decrement int (--) node, but using the subtract node works. Can anyone please explain why this is? Is this a bug, or a misunderstanding I’m having?
I’m assuming this is because it works something like:
decrement int doesn’t call w/ broadcast to do the update, but it changes the value of the variable. Then when the value is received by the manual call to w/ broadcast, it sees that the value received is the same as the value the variable already is, so it doesn’t actually fire the broadcast event?
If this is indeed what is happening, which it likely is, this is a gotcha that should probably be noted in the documentation. Exposing a variable on the set w/ broadcast - something like “force update”, that fires regardless of no change to the underlying variable, would also be a solution to this.