Skip to content

NetworkTransform Teleport() can fail because IsTeleportingNextFrame gets set back to false #3646

@zachstronaut

Description

@zachstronaut

Description

NetworkTransform Teleport() can fail because IsTeleportingNextFrame gets set back to false by CheckForStateChange()

Settings for prefab being teleported:

NetworkObject
SyncOwnerTransformWhenParented = false
AllowOwnerToParent = true

NetworkTransform
Authority Mode = Owner
Switch Transform Space When Parented = true
In Local Space = true

Host Harry with one additional Client Charlie.

Harry spawns the prefab with SpawnWithOwnership() and makes Charlie the owner.

It spawns on Charlie's client and NetworkTransform.OnNetworkSpawn() calls SetState() -> SetStateInternal() -> CheckForStateChange()

CheckForStateChange() sees that InLocalSpace != networkState.InLocalSpace and so it sets IsTeleportingNextFrame=False. But also, networkState.InLocalSpace is set to false rather than true because at the moment of spawning the transform.parent is null:

networkState.InLocalSpace = SwitchTransformSpaceWhenParented ? transform.parent != null : InLocalSpace;

Still on the same frame as OnNetworkSpawn(), Charlie calls Teleport() -> SetStateInternal() which sets IsTeleportingNextFrame = true but then calls CheckForStateChange(). Again, it is still true that InLocalSpace != networkState.InLocalSpace, so it sets IsTeleportingNextFrame=False!

When TryCommitTransform runs, IsTeleportingNextFrame is false. The Teleport does not happen.

Environment

OS: Windows 11
Unity Version: 6000.1.3f1
Netcode Version: 2.4.2
Netcode Topology: Client-Server

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:highThis issue has high priority and we are focusing to resolve itstat:awaiting-responseAwaiting response from author. This label should be added manually.stat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions