Just wondering

Is it better to declare the float stoppingDistance = 0.1f outside the Update method (but still inside the class) to save creating it for each frame?

Scope vs performance shrug

Technically in terms of performance probably (not 100% sure, the compiler might optimize that)
However you should always optimize for code readability first and only do things that negatively impact readability in favor of performance IF you have evidence that performance in that one thing is a serious issue.
Even if the compiler does not optimize that, the performance difference will be in the order of microseconds, so not worth the negative readability cost.

3 Likes

ok thanks, appreciate getting the opinion of someone who has made a lot more games than I have

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms