Assign event on value changed.

I’m trying to make a progress tracker widget that every time the value of an int node is changed to play an animation and to display the progress. Tho the problem is that I don’t know how to assign an event when the int value is changed. I tried making the int node in ‘RepNotify’ mode but using the function that it created when I did it the widget animation didn’t even play. which is strange because my main level was the only one that it didn’t want to play. I tried on some other levels and the animation did play.
WidgetCode:


if you need any further info just ask me. Thanks in advance.

Hey @DeiankataTV!

From what I can see here, it’s possible that you’re overcrowding tick and missing events because of that. GetAllActorsOfClass is very pricey. What I would suggest is doing that on BeginPlay, and setting them as reference variables so the tick knows where to look instead of searching the whole scene. It’s possible that since your main level is where the issue is, and I assume that’s the one with the most actors, TICK is spending all it’s time searching and comparing every actor in the scene multiple times per frame, and that’s causing it to miss your events.

ALL THAT SAID. That might not be the problem. But looking at this one picture I see it being a large possibility :slight_smile: so give that a try and get back to us!

I’m gonna give it a shot, but there at the end, I just let my inside voice talk, and I went in an absolutely different direction from the base topic which was is there any way to assign events on int value changed?

There’s not a node for it. I would suggest running the event off of a check (is new int = old int? if false, run Event). Try to find a way to do it that isn’t on tick. IF it was on tick, you would

  1. GET “current int”
  2. compare to “old int”
    3a. if = do nothing
    or
    3b. if =/= set “old int” using “current int”
    4b. run event through a Call

And have a Custom event that you would call within that BP.

ok I have a plan but I’m yet to do it, but I did make a theory sheet in paint:


What do you think?

@DeiankataTV Sorry, I’m having a hard time reading it. To be fair, my eyes aren’t so good and have a hard time with drawn lines like this. However, since you seem to be of the mind of design (this is a GREAT skill to have) let me turn you on to flowcharting. This is what official dev companies do for any concept before turning it over to programming.

Google draw is a fantastic program for this, btw. You can turn something out like this in a couple of minutes:

I really suggest looking up some tutorials on flowcharting since you seem to be someone who can visualize like that.
It’s absolutely integral to design.

If all else fails, consider telling us what is actually happening in the game / project. From the player’s point of view, and without going into technicalities and jargon.

  • there are shelves full of Cans of Soup
  • the player’s UI says we have 0/3 Cans of Soup
  • when we pickup a Can of Soup from the shelf, the UI represents this progress, now we have 1/3 Cans of Soup; and so on until we have them all
  • I need to represent this with text 0/3 and a progress bar at the same time

How close am I? If not so much, do elaborate!


Also, you’ve chosen the worst possible tool to find all that soup, the engine specifically tells you not to:

image

Not only that, but this will simply not work at all for reasons too numerous to mention atm. You need a radically different approach regardless of what is going on.

well, I did it but it was… well let’s just say that there were better ways to do it, but I just set a variable inside the widget that starts from 1, and every time the variable from the shelf blueprint is equal to the variable from the widget it plays the animation and adds one to the expectation of the equal node (I’m not sure how to say it exactly) and I made 3 variables in the widget for the 3 separate shelves.
It’s probably not as efficient as other ways, but it is what it is.

(Also I changed it to get a copy on event begin play and to use that)