Skip to content

NetworkRigidbody never syncs velocity, especially problematic for Distributed Authority #2903

Open
@Yoraiz0r

Description

@Yoraiz0r

Description

I witnessed bugged behavior when a rigidbody switches ownership in distributed authority, using the Transferrable flag without RequirePermission.

The symptom was such that once the object switched its authority from playerA to playerB, it would change how it moves.

This is because velocities (linear and angular) are not synced at all. I've confirmed as much in NGO 2.0.0-exp2's code.
All NetworkRigidbody/NetworkRigidbodyBase does is manipulate the interpolation and kinematic state, and registers itself onto the network transform.
The network transform has no awareness of the concept of neither linear nor angular velocities. It does not add any of them to its states.

Because of that, given even small amounts of lag, two objects can have wildly different opinions of how a non-kinematic rigidbody should be moving, and because of that, ownership cannot be easily transferred over.

Reproduce Steps

Though I have not used these exact steps, I have a simple project wherein I display the linear and angular velocities of a sphere being rolled by two players, the values show that despite the sphere rolling around when controlled by another player, its actual velocity values are zero'd out. See it here.

  1. Create a new project using NGO 2.0.0-exp2
  2. Create a scene with a NetworkManager and a way to host & join
  3. Add a sphere with a NetworkRigidbody, NetworkTransform, NetworkObject and set it to have Transferrable as true.
  4. Add a NetworkBehaviour that would set the rigidbody's linear velocity to a non-zero value (such as Vector3.Forward) on authority alone, on spawn.
  5. Add a button to allow claiming of ownership to another player.
  6. Begin a pair of player instances and make them join each other
  7. Witness the sphere moving for both players in a direction
  8. Let the joined player claim ownership of the sphere
  9. Witness that the sphere has stopped moving, because it has no linear velocity on its new owner.

Actual Outcome

Velocities are misaligned across clients, causing mismatch on ownership transfer.

Expected Outcome

Velocities are aligned and similar (identical) across all clients, allowing easy ownership transfer.

Screenshots

See the sample here, where

  1. The objects are colored based on their owner's client Id
  2. The top view shows editor gizmo overlays of linear velocity (top row), and angular velocity (bottom row), of the sphere.

The editor client represents the red player, Witness that while the sphere is blue, it has no/almost no linear velocity, despite moving.

Environment

  • OS: Windows 10
  • Unity Version: 6000.0.0b13
  • Netcode Version: 2.0.0-exp2

Additional Context

I don't see any easy way to solve this one without editing the NetworkTransform class such that its synchronized state includes linear and angular velocities. I recognize this is far from an ideal solution, though.

There is no way to append new information to NetworkTransform state, nor is there any way to match its update rates, or interpolations.

At best, right now I'm experimenting with making a network behavior that uses network variables to store linear and angular velocities, and on ownership change, if you became the owner, apply those. I don't think this is the best nor right solution, and it lacks the whole 'unreliable deltas' etc based details that NetworkTransform supports.

Would love to know what's the proper way to go about solving this in the immediate, please!

Metadata

Metadata

Labels

stat:awaiting-responseAwaiting response from author. This label should be added manually.stat:importedStatus - Issue is tracked internally at Unitytype:bugBug Reporttype:feature-2.xNew NGO 2.0.0 feature, request or improvement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions