I have a power up mesh that gives a player power that I would like to take away after a set amount of time assuming the player didn’t pick up another power mesh. I have tried setting up a function that gets the time variable (which is 5), minus that by one, then sets that time. Then I tried calling that function after the player receives a power up, and check the time by using a branch node to make sure the time is not equal to zero. If the time is equal to zero then the power up is switched back to primary fire. Needless to say its not working. Any suggestions as to what I should look into more to get a better understanding on how time works?
Try to use timeline. You can setting parameter in timeline to create visual indicator, use end statement to cancel effect, or restatr timeline if you need.
You can use a Timer for that: https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseTimers/Blueprints/
Basically, when the player gets the power up mesh you set the Timer (5 seconds). When the timer has elapsed, it calls either a Custom Event or a Function. In it, you can remove the power up. If the player gets another power up in the meantime, the timer is set again, which means it starts counting again from 5.
Timers in unreal have one huge flaw, they are referenced by normal text name, so if you change name of that function for whatever reason you will lose all connections to timers.
Instead of timer you can create variable that remembers gameTimeInSeconds , then on event tick you check if (current) gameTimeSeconds is greater than that variable + delay. then add branch and you have your own timer without fear of losing reference. IMO such blueprint code is much clearer and easier to read. Also last time i used timers for some reason game was randomly crashing (and stopped when i converted all timers to checking valuse in ontick).
Also most player interactions are fine even if you check them 5 - 10 times per second (instead of 60 times). So i created my own event dispatcher in gameMode (it is easiest blueprint to get reference to) that was firing 10 times per second and i created all my timers based on it. Something like my own custon onTick event.