Can I use LateUpdate instead of editing script order?

Hey,

Quick question: can we use

  void LateUpdate()
    {
        transform.position = (new Vector2(paddle.transform.position.x, paddle.transform.position.y)) + paddleToBallDistance;
    }

instead of script execution order. Unity docs says that LateUpdate will run after Update so it ensures that we get latest paddle position. Thanks

1 Like

Welcome to the community.

Haven’t done that particular part of the course, but in theory, yes, you could use LateUpdate, but I highly recommend you stick to the instructions just in case.

Execution Order can get out of control pretty quickly, since you are not in full control of the project (you are following someone’s instructions), you don’t know if something will be added later that could conflict with that LateUpdate.

Thanks for the reply! Ah, great. I will revert this for the Block Breaker, but will also leave the current implementation on my other project (i like to create something similar based on this tutorial) and see whether i will get any issues in the future.

So I did find a bug after all. Relying on LateUpdate made the ball shoot down when paddle is still moving. I assume because of the late update (and random order of scripts execution) this was causing an issue. Changed it to use script order and now works fine!

1 Like

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

Privacy & Terms