Jitters when reparenting a rigidbody
See original GitHub issueDescription
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
- Setup a scene with two network objects, one is rigidbody
- Parent rigidbody to another object
- Move them by moving the parent one
- 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:
- Created 5 months ago
- Comments:22 (13 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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! 😸
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).