Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: Support for NT-R to be disabled/enabled during gameplay. #3713

Open
JesusLuvsYooh opened this issue Jan 3, 2024 · 7 comments
Assignees

Comments

@JesusLuvsYooh
Copy link
Contributor

NT-R after being disabled (moves) enabled, loses position sync, due to the delta methods.
Needs some kind of resync upon enabling.

Note older NTs and NT unreliable works with this.
Noticed a few places using this method over the years, such as for pickups, vehicles, platforms etc

@MrGadget1024
Copy link
Collaborator

Does calling ResetState from OnEnable cover this?

@JesusLuvsYooh
Copy link
Contributor Author

Does calling ResetState from OnEnable cover this?

I'l give it a try.

@JesusLuvsYooh
Copy link
Contributor Author

Nope @MrGadget1024 Easily reproducible in tanks example. Attach NTR remove NTU, host and join via another player.
On either screen disable NTR on tanks, move around, enable them.
Positions remain wrong.

@JesusLuvsYooh
Copy link
Contributor Author

JesusLuvsYooh commented Jan 25, 2024

Video preview.
(note I'm just disabling parent NTR's here, not turret.).

Kapture.2024-01-25.at.10.18.01.mp4

@MrGadget1024
Copy link
Collaborator

I think I had a similar issue in one of my examples and opted to unspawn > move > respawn to work around it.

@MrGadget1024
Copy link
Collaborator

MrGadget1024 commented Jan 25, 2024

NetworkTransformBase already has this...

protected virtual void OnEnable()
{
    ResetState();

    if (NetworkServer.active)
        NetworkIdentity.clientAuthorityCallback += OnClientAuthorityChanged;
}

 protected virtual void OnDisable()
 {
     ResetState();

     if (NetworkServer.active)
         NetworkIdentity.clientAuthorityCallback -= OnClientAuthorityChanged;
 }

public virtual void ResetState()
{
    // disabled objects aren't updated anymore.
    // so let's clear the buffers.
    serverSnapshots.Clear();
    clientSnapshots.Clear();
}

@ninjakickja
Copy link
Contributor

Yep you cannot disable and re-enable NTR like this. Unless you can trick the OnSerialize to set 'initialState' = true.
I reckon you are better off introducing another bool for OnSerialize/Deserialize to check, in order to reset the positions properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants