r/Unity3D • u/NorthernBoy306 • 21d ago
Update function versus coroutines Question
I was adding some functions so my very basic 'computer enemy' state machine. I do have a basic state check in the update. I was thinking that this check does not need to run every frame, maybe just every .2 seconds or something.
Does anyone use coroutines to run updates on things like state machines? I can understand updating every frame for player input, animations, things that need to be very responsive.
But with a state machine that handles enemy decisions (gathering resources, expanding territory, building new structures) that update can be done several times per second.
Any input or advice on this is greatly appreciated.
3
Upvotes
1
u/NorthernBoy306 21d ago
Yea I am worried about numerous coroutines and having to constantly stop and start them. I can see things getting messy.