com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

NetworkClientTransform cannot teleport without interpolation.

Open kaygundraka opened this issue 2 years ago • 6 comments

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

  1. Include NetworkClientTransform to network player.
  2. 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.

kaygundraka avatar Apr 06 '22 07:04 kaygundraka

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

WhippetsAintDogs avatar Apr 06 '22 13:04 WhippetsAintDogs

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 avatar Apr 06 '22 13:04 kaygundraka

@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;
        }
    }
}

WhippetsAintDogs avatar Apr 06 '22 13:04 WhippetsAintDogs

@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.

kaygundraka avatar Apr 07 '22 00:04 kaygundraka

Added to backlog MTT-3228

ashwinimurt avatar Apr 07 '22 02:04 ashwinimurt

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?

DovydasAL avatar Apr 08 '22 22:04 DovydasAL

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

ashwinimurt avatar Aug 22 '22 18:08 ashwinimurt

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

ashwinimurt avatar Aug 22 '22 19:08 ashwinimurt