Open Yoraiz0r opened 7 months ago
In attempt to further mitigate problems with ownership change in rigidbodies, I tried making ownership changes occur purely by distance to closest player. This clearly shows how the velocity is lost as soon as ownership is transferred.
The jitter is a result of the remaining linear and angular velocity on the client that originally pushed the object. They don't get cleared by the transfer.
Adding a NetworkBehaviour
that synchronizes and applies linear and angular velocity helps mitigate the problem but ownership transfer is still subject to the lag that comes with the switch, arguably worse looking than on just touch.
Given the position is rolling back, I believe this is more of a NetworkTransform issue than a Rigidbody issue, though.
Hello! Have you fixed it? I'm making a soccer game and can't sync the ball object in any way...
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.
NetworkManager
and a way to host & joinNetworkRigidbody
,NetworkTransform
,NetworkObject
and set it to haveTransferrable
as true.NetworkBehaviour
that would set the rigidbody's linear velocity to a non-zero value (such as Vector3.Forward) on authority alone, on spawn.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
The editor client represents the red player, Witness that while the sphere is blue, it has no/almost no linear velocity, despite moving.
Environment
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!