NetworkTransform.Teleport client-side interpolation issue
Description
When using a server authoritative NetworkTransform model while also using NetworkRigidbody and Rigidbody, if you attempt to teleport a NetworkObject from one location to the next the client-side will interpolate from a position close to the source teleport location and will interpolate to the destination location.
Reproduce Steps
- Create a project where you have dynamically spawned objects from a NetworkPrefabHandler pool
- Make sure the spawned object's NetworkTransform can have its interpolation toggled on/off (user key intput etc)
- Start a host and at least one additional client
- Teleport spawned NetworkObjects from location A to location B (make them relatively far from each other)
- While teleporting, turn interpolation on and note how the client-side will appear at location B briefly but will then "warp back" close to location A and interpolate to location B.
Actual Outcome
It appears that just waiting 1 frame is not enough to properly teleport NetworkObjects and clients will see the teleported object interpolate from location A to location B
Expected Outcome
When teleporting NetworkObjects, there should be a way to completely clear out the interpolation history in order to prevent this from happening.
Project
Project where you can see this happen
Environment
- OS: Windows 10
- Unity Version: 2021.2.10f1
- Netcode Version: 1.0.0-pre.7
This is already fixed.
Fixed in https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/pull/2110/ on develop