Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question NGO NetworkTransform - Temporarily disable interpolation?

Discussion in 'Netcode for GameObjects' started by lcompton, Apr 27, 2022.

  1. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    108
    Is there a way to temporarily disable interpolation in the NetworkTransform component? I have teleportation points in the game space and when the transform position is changed in the player game object, the client version of the avatar gets interpolated through the game space rather than jumping to the final position in one frame. In general, I want interpolation to be enabled, since it smooths out the avatar motion in the client.

    I have tried to set the "Interpolate" value directly in code. I'm able to set the initial avatar position successfully without interpolation. However, when I hit one of the teleportation points, the avatar is interpolated even after setting the value to false.
     
  2. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    108
    I just found the "NetworkTransform.Teleport()" method, which seems like it's what I'm looking for. However, the client is still interpolating the location. I'm running "Teleport()" from the server presently. I'm not certain where it should be run from. I'll try it in the client next.
     
  3. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    108
    I tried "NetworkTransform.Teleport()" from the client and received an exception stating "Teleport not allowed". I'm not surprised. It seems like it should be happening on the server side and then synced to the clients.

    Running "NetworkTransform.Teleport()" does move the player avatar to the desired location, but the client is definitely interpolating. I've looked over the source code and it's clear that interpolation is not intended. Does anyone know of a workaround?
     
  4. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    108
    Deive_Ex and GeorgesAbitbol like this.
  5. GeorgesAbitbol

    GeorgesAbitbol

    Joined:
    Apr 11, 2014
    Posts:
    6
    Thanks for sharing, link solved my problem.