P
P
Pragma Games2021-12-02 11:45:56
Unity
Pragma Games, 2021-12-02 11:45:56

What will happen if you work with physics in Update?

Perhaps the question was raised a little incorrectly, I'm wondering how unity behaves if, for example, in update I will produce Physics.RayCast. After all, any request to work with physics is processed in FixedUpdade.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
GavriKos, 2021-12-02
@PragmaGames

Raycast will work where you call it - it will not go anywhere in the fixed update.
When they say that "physics works in fixed mode" - it means that the physical engine itself considers changes in objects in fixed mode. It follows from this that if you work with physics in an update, then the states of objects may not be updated, for example.

N
Nekit Medvedev, 2021-12-02
@NIKROTOS

Not processed, but should be processed.
In the case you describe, the speed of the physical process will directly depend on the number of processes (load), as a result, the result of the process performed may differ both on different computers, tau and on one, from session to session, depending on the load of third-party applications.

F
freeExec, 2021-12-02
@freeExec

Main difference?
Update - tied to FPS, can be called once per second. And deltaTime you will also get 1s, and if you move the object, then immediately it will fly away from you far beyond 1 time by a conditional 1m.
FixedUpdate - will call as often as specified in the settings. Even if it doesn't keep up, it will be called as many times as needed. Therefore, in the same second that Update is called with FPS=1, FixedUpdate will be called 60 times (with default settings). And therefore, you will move the object by the same 1m, but still for 60 checkers, and maybe somewhere in the middle of the path a trigger will work or something.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question