#Problem with syncing player movement

1 messages · Page 1 of 1 (latest)

orchid barn
#

The problem:
Player jitters ( no matter the smoothing option i choose) ( only on ship )

The context:
Ship uses Kinematic Rigidbody > easy to sync between clients.
Player uses Dynamic Rigidbody > the only way i found to solve jitter in singleplayer.
For multiplayer, syncing Dynamic Rigidbody was not advised to me, so currently only syncing position.

Position sync works perfectly on ground, but on ship the player jitters.

All other players’ colliders and movement scripts are disabled, so the player is not being pushed by ship physics + network simultaneously.

Video is attached.

Code:

public class NetworkCharacter : NetworkBehaviour
{
    public override void OnNetworkSpawn()
    {
        if (!GetComponent<NetworkObject>().IsOwner)
        {
            GetComponent<Rigidbody>().isKinematic = true;
            GetComponent<CapsuleCollider>().enabled = false;
            GetComponent<PlayerMovementRigidbody>().enabled = false;
            //GetComponent<Renderer>().enabled = false;
        }

    }
}

Player Movement & Ship Movement scripts:
https://pastebin.com/Fxn4fPBA

outer pagoda
#

damn thats tuff

harsh sleet
orchid barn
harsh sleet
#

You can but the physics update and network updates do not match up so end up with jitter. The other option is to change the Physics.simulationmode to Script and then call Physics.Simulate() manually after the network transforms update.

orchid barn
#

Have never worked with this before. Smh like this?

public class NetworkCharacter : NetworkBehaviour
{

    void OnEnable()
    {
        NetworkManager.Singleton.NetworkTickSystem.Tick += OnNetworkTransformUpdated;
    }

    void OnDisable()
    {
        NetworkManager.Singleton.NetworkTickSystem.Tick -= OnNetworkTransformUpdated;
    }

    void Start()
    {
        Physics.simulationMode = SimulationMode.Script;
    }

    private void OnNetworkTransformUpdated()
    {
        Physics.Simulate(Time.fixedDeltaTime);
    }

    public override void OnNetworkSpawn()
    {
        if (!GetComponent<NetworkObject>().IsOwner)
        {
            GetComponent<Rigidbody>().isKinematic = true;
            GetComponent<CapsuleCollider>().enabled = false;
            GetComponent<PlayerMovementRigidbody>().enabled = false;
            //GetComponent<Renderer>().enabled = false;
        }

    }
}

#

hahahah first of all game feels like it runs in 10 fps now cuz physics update so rarely, second of all jitter changed yea but didnt disappear