Unity, Update, FixedUpdate, LateUpdate the difference (rpm)

void FixedUpdate () fixed Update

void Update () Updates

void LateUpdate () after the updates

 

FixedUpdate () 和 Update ()     

With: MonoBehaviour When enabled, it is invoked in every frame. They are used to update

Iso: Update () time per frame is not fixed, i.e. the first frame and the second frame and the time to third frame and the fourth frame is not necessarily the same t2 t1. FixedUpdate () between each frame and the time difference for each frame is fixed.

Update by the impact of the current object rendering, which is the current scene being rendered objects related (such as the number of characters face, number, etc.), sometimes fast and sometimes slow, frame rate will change, Update is called interval occurs Variety. But FixedUpdate the frame rate is not affected by the change, which is based on a fixed time interval to be called.

So some physical property of the update should be placed FxiedUpdate operation, such as Force, Collider, Rigidbody like. The operation is also peripheral, such as a keyboard or mouse input and output Input, such as smoother performance GameObject physical, closer to reality.

FixedUpdate time interval can be changed in the project settings, Edit-> Project Setting-> time to find Fixed timestep. You can modify the

 

Update和LateUpdate

LateUpdate is called after all the Update function calls. Scripts can be used to adjust the order of execution. For example: When an object moves Update, the camera follows the object can be achieved in LateUpdate years.
 Unity backstage main thread Update LateUpdate made into two multi-threaded execution Update to go to the thread, and so finished in Update to perform LateUpdate thread.
For example, a dormitory four people, each person get up in the implementation of the update, starting in lateupdate execution of certain people, so that you can guarantee that everyone will get the start.

Because the update function is more the order is random, it is possible to update the camera and the object has not moved, and the next frame if the object is the first update of the situation it will teleport appear. Most cameras should be added LateUpdate, that is, after the end of all calls within the camera scene update.

For example: There are two different scripts while controlling an object in Update, then change the script when one object orientation, rotation or other parameters, another script is changing these things, then the orientation of the object, the rotation will be certain recurring. If there is an object follow the object moves, rotates in the Update, then follow the object will appear jitter. If it is to follow in LateUpdate in, it would only follow the final position after the implementation of all Update, rotate, thus preventing jitter.

Guess you like

Origin www.cnblogs.com/91-JiaoTeacher/p/11492772.html