![]() ![]() I finally received a variation of the code from Duhprey on the Unity forums and his code worked great for me. Avg ping is around 2-3ms because I'm actually over wifi, but its still fine. I've tested on both my own server and the Photon cloud server with the exact same results. I had several different variations of the original NetworkRigidBody but none worked as advertised. Rigidbody.angularVelocity = latest.angularVelocity Transform.rotation = angularRotation * latest.rot Transform.position = latest.pos + latest.velocity * extrapolationLength Quaternion angularRotation = Quaternion.AngleAxis(axisLength, latest.angularVelocity) If (extrapolationLength < m_ExtrapolationLimit)įloat axisLength = extrapolationLength * * Mathf.Rad2Deg Don't extrapolation for more than 500 ms, you would need to do that carefully Transform.localRotation = Quaternion.Slerp(lhs.rot, rhs.rot, t) įloat extrapolationLength = (float)(interpolationTime - latest.timestamp) Transform.localPosition = Vector3.Lerp(lhs.pos, rhs.pos, t) T = (float)((interpolationTime - lhs.timestamp) / length) Go through buffer and find correct state to play back Check if states are in order, if it is inconsistent you could reshuffel or M_TimestampCount = Mathf.Min(m_TimestampCount + 1, m_BufferedState.Length) filled up and that uninitalized slots aren't used. Slots aren't actually freed so this just makes sure the buffer is Update used slot count, however never exceed the buffer size Shift the buffer sideways, deleting state 20įor (int i = m_BufferedState.Length - 1 i >= 1 i-) Vector3 angularVelocity = rigidbody.angularVelocity Void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) We store twenty states with "playback" information Public double m_ExtrapolationLimit = 0.5 Public double m_InterpolationBackTime = 0.15 //0.15 = 150ms Raise the sendrate if you want to lower the interpolationBackTime (or vice versa) By default this is 10 times/second for OnSerialize. NOTE: Network interpolation is afffected by the network sendRate. Public class NetworkRigidbody : Photon.MonoBehaviour ![]() Example code from the unity networking examples Then I'll upload a video if its not resolved by then. I'm waiting on a new network capture card, should be here any day. This is a show stopper and I'm not ready to give up. I even commented out the prediction code thinking it was moving too far forward, then it had to back up and reset, but I still had the jitter. Is there another version of NetworkRigidBody that works better? Might it be an issue with prediction? I'm traveling perfectly straight, no turning, so even prediction should be pretty simple. If my client isn't moving and the remote avatar is moving I notice the jitter, but if we're both traveling in the same direction at the same speed, and I'm very close to the other player, I see the other player jitter very bad. I've taken time to diagnose the code and I understand it and I'm pretty confident the code looks valid. I'm using NetworkRigidBody and Unity4, I have Observed set to NetworkRigidBody, with it enabled on both the sending and receiving sides. I've scouered the boards, but haven't found the resolution and I know its gotta work. If I remove "networkView.isMine" it just lets me control both vehicles from both host and client.I have everything working great, almost done the alpha build of my game, but this network jitter is preventing me from releasing anything. But as a client I'm not able to control any vehicles. If there are two players on the server and I am the host, I'm able to control both vehicles. Any examples or articles would also be appreciated. I need a short description how I would go around this. Wouldn't it be better to keep things separated? But I don't like how player object is enabled from the Networking-class. I found this video on how to create authoritative networking, which is a good start. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |