Game Development Reference
In-Depth Information
LateUpdate()
The
LateUpdate()
function is called every frame after all the
Update()
functions
have been called, if the
MonoBehaviour
class is enabled.
LateUpdate()
is called after all
Update()
functions have been called. This is useful
to order script execution. For example,
follow camera
should always be implemented
in
LateUpdate()
, because this tracks objects that may have moved inside
Update()
.
An example of
LateUpdate()
is as follows:
// JavaScript user:
// Moves the object forward 1 meter per second
function LateUpdate () {
transform.Translate(0, 0, Time.deltaTime*1);
}
// C# user:
// Moves the object forward 1 meter per second
void LateUpdate () {
transform.Translate(0f, 0f, Time.deltaTime*1f);
}