Since the aiming direction will always be the same during the duration of the Aiming state, would it not make better sense to calculate the aiming direction once in TakeAction() and then use that value in Update() rather than recalculating it in each frame?
Sure that would be more performant but on the order of microseconds. So technically yes but unless you have thousands of Units aiming at the exact same time then it’s not really an issue.
Thanks for the reply!
I’ve been working in the video game industry for almost two years now and I’ve found I’m getting accustomed to looking for any memory/time saving refactors possible.
I have a similar mindset, always seeing something that could be just that much more faster. Often, in the rough development stage of a game, these optimizations can get in the way of the creative process.
As a rule of thumb, during prototyping, if it’s a quick fix, for example:
- Caching component references that would otherwise be called repeadly in Update()
- Caching a quick calculation
Otherwise, I’ll mark it with a TODO and work on it in a later pass on the code.
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.