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

Player spawns at old position for a single frame on clients #3204

Open
daalen opened this issue Jan 14, 2025 · 2 comments
Open

Player spawns at old position for a single frame on clients #3204

daalen opened this issue Jan 14, 2025 · 2 comments
Labels
stat:awaiting triage Status - Awaiting triage from the Netcode team. type:support Questions or other support

Comments

@daalen
Copy link

daalen commented Jan 14, 2025

The clients have authority over their own players' transform. When a player dies, I disable the player object, set it to a new spawn position, and after a few seconds activate it again to have the player respawn. The position is set on both the controlling client and the server (rigidbody position too) with the teleport flag on. When interpolation on the networktransforms is off, everything works. When it is on, something weird happens on the clients that do not control the player: when reactivating the gameobject, the player appears where they died for a frame or so, and then is quickly interpolated to the correct spawn position. The server just sees it at the new spawn position like it should.

How can I avoid the player appearing at their old position when reactivating the gameobject? While inactive, it's in the correct (new) position, but somehow it shifts back for a tick when activated.

If I delay reactivating the gameobject on other clients by 0.1 seconds, it all works without this weird effect, but this is an uncomfortable hacky solution to me.

@daalen daalen added stat:awaiting triage Status - Awaiting triage from the Netcode team. type:support Questions or other support labels Jan 14, 2025
@NoelStephensUnity
Copy link
Collaborator

Hi @daalen,
Are you despawning the player or just setting it to be inactive? If you are just setting it to be inactive, then I would recommend despawning using NetworkObject.Despawn(false); and then respawning the NetworkObject after having re-positioned it.

@NoelStephensUnity NoelStephensUnity added the stat:awaiting response Status - Awaiting response from author. label Jan 17, 2025
@daalen
Copy link
Author

daalen commented Jan 17, 2025

I'm not despawning it, because I have a load of references set up from and to the player that take some back-and-forth Rpcs at the initial spawn.

@michalChrobot michalChrobot removed the stat:awaiting response Status - Awaiting response from author. label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting triage Status - Awaiting triage from the Netcode team. type:support Questions or other support
Projects
None yet
Development

No branches or pull requests

3 participants