question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jitters when reparenting a rigidbody

See original GitHub issue

Description

Following this part of the documentation I’m trying to implement the carrying behavior. It works, but with noticeable jitter when character drops the object.

This is my pick up code (it actually matches the documentation example):

GetComponent<NetworkObject>().TrySetParent(newParent);
GetComponent<Rigidbody>().isKinematic = true;
GetComponent<NetworkTransform>().InLocalSpace = true;
transform.localPosition = newParent.InverseTransformPoint(handlePosition);

And drop:

transform.transform.parent = null;
GetComponent<Rigidbody>().isKinematic = false;
GetComponent<NetworkTransform>().InLocalSpace = false;

Reproduce Steps

  1. Setup a scene with two network objects, one is rigidbody
  2. Parent rigidbody to another object
  3. Move them by moving the parent one
  4. Set rigidbody’s parent to zero

Actual Outcome

Object teleports for a moment to 0,0,0 (apparently, not sure) and then teleports back to its correct position. Also, it also participates in physics simulation, so it can move other objects located in 0,0,0 (you can see on the video that it pushes another character)

Expected Outcome

Object should persist it’s current position without teleports or jitters

Screenshots

Host is on the left. Jitters appear only on the client.

https://user-images.githubusercontent.com/5504685/232324945-be4b15d3-17f1-4824-be27-a76def1f850e.mp4

Environment

  • OS: Windows 11
  • Unity Version: 2023.2.0
  • Netcode Version: 1.3.1, I also tried it with develop branch, the same results.

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:22 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
NoelStephensUnitycommented, Apr 22, 2023

Excellent! 🚀 Feel free to reach out to us any time, and if later in your development cycle you feel like you have achieved (or are getting close to achieving) your project’s goals we always love to see the progress made!

Happy Netcoding! 😸

1reaction
NoelStephensUnitycommented, Apr 21, 2023

Ok, I think I have a solution but it might require a slight minor update to NetworkTransform. Same concept, just need to handle resetting the interpolators when a NetworkTransform is enabled when already spawned. Both sides still place the Cube under the socket… there is a timing issue with switching between Kinematic and non-Kinematic when dropping (it can collide with the player and cause slight bouncing off of the player), but that type of issue is easily handled. Will post the solution and have a PR up for the minor change (since you are pointing to the develop branch anyway).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jittery movement while rotating the object with using ...
Hello, I have problems about rotation. I have a ball and I am rotating it with using Rigidbody. public Vector3 rotationSpeed = new ......
Read more >
Jittering when moving rigidbody by changing its velocity.
This causes the camera to jitter moving and rotating the camera. What can i do to stop this? Here is my movement script....
Read more >
Rigidbody appears to jitter when placed as a sibling ...
In my game, the Player can pick up an object (which gets parented to the first-person camera), or the player can push an...
Read more >
Fix RigidBody Jitter in One Click - Unity Quick Tips - YouTube
... In this game dev tutorial I will show how to easily fix visual jitter issues with your Rigidbody in Unity. #gamedev #unity...
Read more >
Manual: Apply interpolation to a Rigidbody
The Interpolate setting on a Rigidbody provides two options to smooth the appearance of a Rigidbody's motion if it appears jittery at run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found