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

Object Stuttering With Rigidbody Interpolation Enabled #3965

Open
ep2274 opened this issue Dec 31, 2024 · 1 comment
Open

Object Stuttering With Rigidbody Interpolation Enabled #3965

ep2274 opened this issue Dec 31, 2024 · 1 comment

Comments

@ep2274
Copy link

ep2274 commented Dec 31, 2024

QUICK NOTE:
This was discussed in the discord in the help forum under the title "Transform.position not updating for networked objects" by @EPCubed (me). I've tried many times to replicate this, but the conditions are weird and the bug is hard to see sometimes graphically. It can happen without the user seeing any weird position changes. Thus, the steps on replicating are a little weird. You might have to do some extra tinkering to see it visually happen.

Describe the bug
Unowned objects on clients with Rigidbodies and NetworkRigidbody (Reliable) components under specific conditions have position stutters that change over time. The stutter position seems to change when the Rigidbody is asleep, The stutter likes to occur when moving out of sleep.

Requirements for the Rigidbody component are:

  • Interpolation mode set to interpolate
  • Freeze rotation on all axes
  • Maybe continuous collision mode (I've only done testing with this on)

Requirements for the NetworkRigidbody component is default with no changes to it.

[IMPORTANT] How can we reproduce the issue, step by step:

  • Create a new project. I used Unity 2022.3.43f1, but I believe it should work on any LTS 2022 version.
  • Import Mirror. I used version 93.0.1 from the asset store
  • Make some ground by creating a cube and stretching it out horizontally.
  • Create a Sphere GameObject. Make sure it has a Sphere Collider.
  • Add a Rigidbody to the Sphere. Enable interpolation and continuous collision. Make sure to freeze all rotations.
  • Add a Network Identity and NetworkRigidbody (Reliable) to the Sphere, and turn it into a prefab. You don't need to change any values of the NetworkRigidbody.
  • Add this simple sphere moving script as a component to the Sphere: PastieLink
  • Assign the Rigidbody component to the new script
  • Make the Sphere object a prefab
  • Create a new GameObject and give it the NetworkManagerHUD and assign a default KCP transport to the manager.
  • Assign the player object to be the Sphere prefab
  • NOTE: This is the weird and tricky part. You might have to adjust the values below to get the glitch to appear visually for you depending on your monitor or computer specs!
  • Go to time preferences and make sure that the FixedTimeStep is 50 FPS 0.02
  • Change the send rate of Mirror to be 100 (this makes the bug usually appear more often for me)
  • IMPORTANT: This part may or may not help. Try following the steps after this one first, and then do this one if you don't see it. You can create an new object with a component to set the FPS to the FixedUpdate FPS which has helped me see the bug in some cases more often. Code is here: PastieLink
  • Build the project! (You might be able to get this to work on Editor as well, but building it is more reliable)
  • Run two instances with one as server + client and the other as just client
  • If you start moving and stopping repeatedly (WASD controls), you should see the unowned sphere on the other client's side stuttering between previous positions and its current one. I will try to include a video to show this off. Even if it doesn't occur visually, the transform position sometimes reports as this old stuttery position, and the object can perform "phantom teleports" where it stutters positions without visually showing it. The discord post illustrates this phenomenon better.
    -If you are experiencing the bug, try pressing the I, as in Illustrator, key to toggle the interpolation. When toggled off, you shouldn't see stuttering anymore.

Expected behavior
If everything goes right, you should see stuttering for the unowned sphere's position. If not, you might need to adjust some of the values above like the FixedTimeStep or Send Rate of Mirror. I have been able to replicate this 3 times now, so it does definitely exist.

Screenshots
I've attached a video of me showing off / explaining the problem. There are also videos of me talking about it in the Discord post mentioned above.
https://github.com/user-attachments/assets/9f91676c-bac2-4208-8ef4-531a8e27dd37

Desktop (please complete the following information):

  • OS: Windows 10
  • Build target: Windows but sometimes works in Editor
  • Unity version: 2022.3.43f
  • Mirror branch: Master: 93.0.1 from Asset Store

Additional context
I've gotten this bug to happen in 2 projects so far with entirely different scripts, so it is independent of outside factors.

Please let me know if you need a project upload and how to do so if you do need that. I'm very sorry for the delay between the Discord post and the bug report. I really appreciate the work you guys do for Mirror! I'm hoping you guys can replicate it successfully.

@MrGadget1024
Copy link
Collaborator

Possible duplicate of #3931

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

2 participants