com.unity.netcode.gameobjects
com.unity.netcode.gameobjects copied to clipboard
NetworkClientTransform cannot teleport without interpolation.
Description
I am using Netcode 1.0.0-pre.6 Version.
In my project, Player prefab is using NetworkClientTransform for moving.
When player tried to teleport using Teleport() Method, player position was interpolated. For this reason, unity3d OnTriggerEnter/Stay/Exit events in all travel paths are triggered.
How to find a way can teleport owned network object of individual clients without interpolation?
Reproduce Steps
- Include NetworkClientTransform to network player.
- Use teleport member method of NetworkClientTransform in script.
Actual Outcome
Network object (owned player) was teleported location with interpolation.
Expected Outcome
Need a way NetworkClientTransform can teleport without interpolation.
Environment
- OS: Windows 10
- Unity Version: 2020.3.30f1
- Netcode Version: 1.0.0-pre.6 (all version happend)
- Netcode Commit: [e.g. https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/commit/ba418fa5b600ad9eb61fab0575f12fbecc2c6520]
Additional Context
It happens to both the server and the client. It happens even if you play alone.
Hi @kaygundraka, I think it's a duplicate of a bug I've filed:
https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/1759 https://issuetracker.unity3d.com/issues/networktransform-dot-teleport-interpolates-on-client-when-another-transform-change-occurs-on-the-same-frame
Hi @kaygundraka, I think it's a duplicate of a bug I've filed:
#1759 https://issuetracker.unity3d.com/issues/networktransform-dot-teleport-interpolates-on-client-when-another-transform-change-occurs-on-the-same-frame
Thank you, I voted that issue too.
@kaygundraka, if you need a workaround, you can in the meantime do something like this:
public static class NetworkTransformExtensions
{
public static void PatchedTeleport(this NetworkTransform self, Vector3 newPosition, Quaternion newRotation, Vector3 newScale)
{
self.Teleport(newPosition, newRotation, newScale);
self.StartCoroutine(PreventTeleportingStateFromBeingOverriddenAndClampInterpolation());
IEnumerator PreventTeleportingStateFromBeingOverriddenAndClampInterpolation()
{
self.enabled = false;
yield return null;
self.Teleport(newPosition, newRotation, newScale);
yield return new WaitForSecondsRealtime(0.5f);
self.enabled = true;
}
}
}
@kaygundraka, if you need a workaround, you can in the meantime do something like this:
public static class NetworkTransformExtensions { public static void PatchedTeleport(this NetworkTransform self, Vector3 newPosition, Quaternion newRotation, Vector3 newScale) { self.Teleport(newPosition, newRotation, newScale); self.StartCoroutine(PreventTeleportingStateFromBeingOverriddenAndClampInterpolation()); IEnumerator PreventTeleportingStateFromBeingOverriddenAndClampInterpolation() { self.enabled = false; yield return null; self.Teleport(newPosition, newRotation, newScale); yield return new WaitForSecondsRealtime(0.5f); self.enabled = true; } } }
Thank you guy!.
I've seen solutions in netcode-discord channel. The code has been temporarily applied.
In my case, it doesn't solve perfectly. When teleporting to a faraway place in the open world game, admission is processed to the dungeon located in the middle.
Added to backlog MTT-3228
Using this temporary solution, I'm noticing jitter on the client. If the client teleports, waits a little bit, then moves, it's fine. However, if they teleport then move shortly after, it makes them jitter before moving. Any ideas to fix this?
This is probably fixed on develop
. Assigning to @NoelStephensUnity to close this issue.
Duplicate of https://jira.unity3d.com/projects/NCCBUG/issues/NCCBUG-163
PR with fix: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/pull/2110
Hi @kaygundraka This issue is fixed on develop and will be part of the upcoming 1.0.1 release. Could you please verify and let us know if you are still seeing issues. Thanks