Run animation in widget only once?
I'm trying to run an animation to remove lock symbol from level selection once the player has completed said level. Is there an event that only fires the first time the widget is opened and never after that? Or do I have to make a save game and then save a boolean there to see if the animation has been played before or not? It's just that I have many levels in my level selection screen and each level has a lock symbol at the beginning, so I would have to add many booleans in my save game to keep track of which levels are unlocked and which are not. Feels like there should be a better way to do this?
I'll clarify further if something was unclear, and can post pictures if you have trouble visualizing what I'm trying to do.
asked Mar 01 '19 at 04:09 PM in Blueprint Scripting
There is no such event. You can play an animation on Construct Event, but it plays every time this UserWidget is created. You can also do some logic to prevent it from playing again, but there is a problem:
If your levels begin locked, you have to store their status during save anyway, because when the game is closed and restarted, there is no other way to know what happened during the last gameplay session, unless you store changes on disk (save).
Your level script, data struct, save file (can't tell for sure, because I don't know your game scripts) should have a boolean/Enum property that tells if the level is unlocked, this property needs to be saved.
When a "Level Selection Screen" is created, each level widget get its status from the save game and shows the lock icon accordly.
When the player completes a level, you should check this property to know if an animation should play or not.
PS: There are lots of other methods and optimizations you can use, for example, if your level progression is linear, you can store just the last unlocked level, and all previous levels knows that they should be unlocked as well.
Follow this question
Once you sign in you will be able to subscribe for any updates here