Smooth follow/look at and rigid bodies.

So I’ve been working on implementing some smooth follow/look at functionality for our project.

There are 2 ways that I know of of doing it:

  • Perform the smooth follow logic in the LateUpdate(). It is all good because LateUpdate will be called when all Updates have finished, so you are always guaranteed to get the up-to date position.

But when the object that you are following is a rigid body that is being controlled by physics, things don’t look as bright.
The controlled object starts to “jiggle” awfully. Can make a video upon request.

Interesting thing about this jiggle is that it won’t at all happen if you pause the game and then do a step by step, it only happens when you hit Play. This makes me think that it has to do with multi threading and the fact (speculated guess) that physics runs in a different thread and things don’t synchronize well somehow.

  • Implementing the smooth follow/look at logic inside of the FixedUpdate():
    So, you might say that this sounds about right. If it doesn’t work in LateUpdate, then it has to in FixedUpdate.
    This solves the jiggle but introduces another serious problem:

Since FixedUpdate for a specific frame is called before the physics is performed, you are never getting the up to date position of the followed object, but rather the one of the previous frame.
This introduces very noticeable jumps when the rigid body speed changes rapidly (for example if it hits the wall).

So neither of the two ways actually work for me at these late hours :frowning:

Any ideas?
Thanks beforehand,
Gennadiy

This also happens on Unity 2.6 as well, not just 3.0.

It seems like the problem could be solved if it were possible to run code in a fixed physics loop but AFTER the physics was performed.

Does anyone know of a way to do that?

Thanks again,
Gennadiy