I now have a physical cube A, which is influenced by the physical simulation inside the engine. I have created another non physical cube B, which will obtain A’s transform information every frame(code in Update function) and copy it to its own transform. Therefore, theoretically, A and B should overlap with each other. However, in actual operation, I found that B always takes half a beat slower than A, resulting in the inability to overlap. Why?
First, physics happen in FixedUpdate, not Update
Second, if you put it at FixedUpdate code, it would be executed before engine physics update, which would cause second cube to lag one frame behind. You can read about it here
If you want second cube to match the first one you would probably need to put it inside a WaitForFixedUpdate coroutine? Not sure about this one tho.
Edit: nevermind, I didn’t realize that according to that page I linked if you set cube B position at A cube position, it should always match, since Update called every frame, and after physic update. I apologize, and also wondering what went wrong here.
Tho I have a guess, did you turn interpolation on for rigidbody of A? If yes it may cause that lag.