Mirror icon indicating copy to clipboard operation
Mirror copied to clipboard

feature: NetworkRigidbody (snapshot interpolation)

Open miwarnec opened this issue 4 years ago • 8 comments

NetworkRigidbody component based on Snapshot Interpolation.

  • Rigidbody only ever modifies Transport component
  • NetworkTransform already syncs Transport component
  • NetworkRigidbody simply inherits from NetworkTransform and sets the RB to kinematic if we don't have authority

before: https://gyazo.com/f9b6f55768a07a38e52a00d3f66693c8

after: https://gyazo.com/040f35daf2d488a2ca5fb369e01a59ce

test via:

  • change tanks projectile script to set velocity in onstartserver only
  • add NetworkRibidbody component
  • see if it syncs like above

NOTE: obsoletes the two experimental ones

TODO: NetworkTransformBase helper: 'can I move this?' bool

miwarnec avatar Sep 05 '21 12:09 miwarnec

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Sep 05 '21 12:09 sonarqubecloud[bot]

Thanks for this! I think it's a good start, and we can add syncVelocity syncAngularVelocity etc later as options IMO

hyouuu avatar Sep 26 '21 20:09 hyouuu

Just tested the current NetworkRigidbody vs the new code, and the new code gives much better result - I have a camera following the rigidbody, which would jump randomly with the current approach because of jittering transform position (I think), whereas the new approach gives a smooth transition which is great.

One issue without syncing the rigidbody velocity though, is that for a fast moving object like a bullet, after I spawn it and give it a large initial force, on client it would stay at the spawn position for a while until gets updated to the next position. So I think being able to sync the initial velocity would be a good option. I'm pretty new to Unity and Mirror so please correct me if wrong.

Thanks for making this better!

hyouuu avatar Sep 27 '21 05:09 hyouuu

What about objects that change authority over the course of the game? One example is VR. Players have client authority over their rigs and when they pick up an object, they are given authority over that object. This would require to set isKinematic to false for the client with authority if the Rigidbody at spawn was dynamic.

tswierkot avatar Oct 12 '21 08:10 tswierkot

This doesn't appear to sync any rb values, so what am I missing? All this seems to do is force kinematic and kill the rb.

MrGadget1024 avatar Nov 14 '21 17:11 MrGadget1024

Where are all these handled?

image

image

image

MrGadget1024 avatar Nov 14 '21 17:11 MrGadget1024

closed by accident - sorry

MrGadget1024 avatar Nov 14 '21 17:11 MrGadget1024

What's the status on this one? Updated Mirror and found it's still not in - maybe a toggle or live alongside original NetworkRigidbody so people have a choice?

hyouuu avatar Feb 09 '22 07:02 hyouuu

@vis2k saw lots of work done recently to Mirror - how do you think about this one could we merge it in some way?

hyouuu avatar Oct 14 '22 09:10 hyouuu

@hyouuu sorry, missed your comment. lets rebase this and get it done. we need a smooth rigidbody.

miwarnec avatar Jun 07 '23 10:06 miwarnec

Good to see progress finally!

hyouuu avatar Jun 08 '23 14:06 hyouuu

closing as mirror has this already now

miwarnec avatar Jan 20 '24 12:01 miwarnec