Cast event when (Variable change)
My question is simple how Custom Event in this case (Event 1) Can be casted whenever Variable change for example. Integer (100) When it comes 99,98,97 etc.. cast Event 1 for every change cast my event ..
asked Jan 30 '18 at 09:52 PM in Blueprint Scripting
Your wording is a little confusing, but I'm assuming you actually want to trigger or fire an event when the variable is changed? Casting is a whole other thing, which you may or may not be aware of, but you do not cast to events, you cast to classes.
In any case, there are different ways of going about doing this, depending on what you're trying to do. You could set the replication of your variable to 'RepNotify' which will create a function for you that will fire every time the variable is changed. Though this method is typically used with networking, so I'm not sure what the result would be if your game is local only. Never thought to try.
If you're using UMG you can 'Bind' a function to a variable, but as far as I'm aware that will call the function every frame, which will get a little heavy depending on what you're doing.
You could also store the current value of the variable in a second variable, then on tick check to see if they are the same. If your variable changes, call your event and set the second variable to match the first again.
What exactly are you trying to achieve? There may or may not be a better way to accomplish whatever you're trying to do.
answered Jan 30 '18 at 10:45 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here