- Home /
Low Priority Methods In LateUpdate?
Hey there, just a quick question! Is it recommended to call all "low priority methods" via LateUpdate? Methods like setting/getting the score and updating it on the UI.
I appreciate any suggestions!
Felix
LateUpdate is called once all the Update() functions your monobehaviour scripts are done processing. (So in your case the scoring operations would be called after all the operations you can have in your updates)
Unless your scoring functions are influencing the game physics you should not pay attention whether or not it should be made in Update or LateUpdate.
I$$anonymous$$O there is no general rule. There are particular cases where you do have to use LateUpdate(), FixedUpdate(), I never encountered them so far as I rarely work with physics.
you also have posts on the forum about the topic, here is one.
Edit : old question.
Answer by YoungDeveloper · Jun 25, 2015 at 12:47 PM
LateUpdate is executed after Update, it would make sense to update camera positions there. Transform is moved in update and later the camera, that would exclude the possibility for camera jitter - camera is updated before actual movement. This is just one example i can think out of the head.
Thanks for your answer! But the actual question is: can I save processing power by Calling these functions from LateUpdate()? It's not that I want to avoid Jittering or something, the score update could be easily called just once every second. Should I start a CoRoutine?
@felixpk yes you could also use a coroutine and invokeRepeating() to update scores every seconds, but you can also do that in update (calling the function every X number of frames).
@felixpk: To answer that question in the comment: No, LateUpdate will not save any processing power as it is called exactly as often as Update, just later during the frame. It's ment to do things "in the right order". So in LateUpdate you can be sure that all Update functions has already been processed for this frame.
LateUpdate is actually the exact same thing as Update just called later. If you want to update something at larger intervals InvokeRepeating would be the best solution. Of course you can also use a coroutine, but InvokeRepeating is easier.
ps: Your original question is very confusing as you presented your "solution" using LateUpdate in a case where LateUpdate makes no sense at all ^^. When you ask a question you should focus on the actual question. In addition you can suggest / ask if a certain method / way might be the solution but the question should be about your actual problem. In your case you probably want to improve performance by not calling certain things every frame but at certain intervals.