Search Unity

Setting Update object position to FixedUpdate object position (js)

Discussion in 'Scripting' started by Warrior1424, Nov 25, 2014.

  1. Warrior1424

    Warrior1424

    Joined:
    Sep 30, 2010
    Posts:
    984
    So I have a strange problem.
    My game is in first person, and uses a rigidbody (cannot use a char. cont.) for the player.
    The only problem is, that I want the player to use FixedUpdate, but I want the camera to follow as if it wasn't using FixedUpdate, as making the camera follow an object directly that is using physics makes it look like the framerate is lower (since FixedUpdate doesn't update as often as Update).

    Here's an image to illustrate what I mean:

    Where A is the player (with the dots being the position as it moves over time in relation to Update)
    And B is the camera (with the line being the desired position as it moves over time in relation to Update)

    But obviously, setting the camera to follow the player directly (like making the camera a child of the player) would make the camera's movement the same as A, which is undesired.

    Has anyone else run into this problem before?
    Is there even a solution to this problem?

    Any help would be great, thanks!
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Turn on interpolation for the player rigidbody.

    --Eric
     
  3. Warrior1424

    Warrior1424

    Joined:
    Sep 30, 2010
    Posts:
    984
    I tried that, but things still look jittery (especially noticeable if for example, looking at an object while you walk in a circle around it)

    The controller itself is not jittery if you move the camera so that it is behind it, but the environment is, and only when moving. If you stand still and look around, it is fine.

    EDIT: With no interpolation, it's a constant jitter.
    With interpolation, only some of the frames appear to be "off".
    Extrapolation yields similar results to that of interpolation.
     
    Last edited: Nov 25, 2014
  4. Warrior1424

    Warrior1424

    Joined:
    Sep 30, 2010
    Posts:
    984
    Any other ideas?
     
    Last edited: Nov 28, 2014