Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

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:
    79
    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:
    79
    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:
    79
    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:
    79
    GeorgesAbitbol likes this.
  5. GeorgesAbitbol

    GeorgesAbitbol

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