Hi everyone! I’m new in the forums and kinda new to Unreal in general and I’m having a bit of a hard time getting to understand how to do some things, for example the topic of this question: how to manage time-based actions?
I’m working on a game where I need to have something happen every couple of seconds (i.e. Hunger meter goes up), but I also need to have the character execute some time-based actions (i.e. Cooking a pizza takes X seconds but cooking a turkey takes Y seconds). Also, some other actors will have their own time-sensitive actions (i.e. Tomato plant will be harvestable every N seconds but will rot if N*5 seconds pass by without harvesting it).
Before we move forward a quick disclaimer: I’m working exclusively with Blueprints, would rather keep it this way but if the only solution is to turn to CPP I will.
I know what I’m describing is nothing ground-breaking, but somehow I can’t seem to find out how to deal with this.
I’ve tried using delays, but this only works on the Event graphs? So I can’t fire a “waiting X time” action in any function that’s not in the event graph.
I’ve tried having an array for all states of an actor that will loop through the array and call event dispatchers that should call other event dispatchers and wait for that before proceding but the loop loops through the entire array in a single frame? (why does it do that? I honestly don’t understand).
I’ve tried Set Timer by Function Name but this only waits before calling a function, which is not really what I want, I want the function to run but spend time running, does that make sense? For example I want the function to print “I’m cooking” and stay cooking for X seconds and then finish.
I’ve tried with while loops, calling functions that return booleans and check those before proceding.
Also I’m trying to manage all this action either in the controller or the game mode, but want each actor to have it’s own information about what actions it can do and how long they take.
And also I want to have modifier that will make the character do their own actions faster and other modifiers for the other actors as well.
I hope this gives you a good understanding of the kind of time-based actions that I need to manage. My question is how to manage all this? What concept am I missing or what blueprint function is the one that I’m not using? Am I wrong in trying to manage this in the game mode or player controller? is there a specific way to handle this sort of stuff?
Any help is appreciated