- Home /
Network Tutorial Interpolation - TPS Auth
I am going over the tutorials now and trying to understand the nuances of interpolation. Using the Authoritative Server scene provided in the Network Tutorial, Lerpz get spawned and can run about atop a small plane.
I have modified this script to make the MainCamera for the connected player track his Lerpz instance. This caused problems that I can solve with input axees. But as I was trying to solve them, I carefully examined the GraduallyUpdateState script to figure out why interpolation wasn't addressing my problem. I noticed something that I don't understand.
I don't think that the client Lerpz facings are being corrected, just their positions. Is there a reason for this? An array of State structures is being carefully maintained and one of the attributes of this structure is the Quaternion "rot". Yet when the client Lerpz position is out of tolerance, only the position gets updated. The facing is never checked against rot, nor is it updated.
Please tell me why. Is the rotation somehow corrected elsewhere? Does it never need correcting? Is correcting it more trouble than it's worth? Code follows.
GraduallyUpdateState.cs:
internal struct State
{
internal double timestamp;
internal Vector3 pos;
internal Quaternion rot;
}
...
Vector3 m_NewPosition;
...
IEnumerator MonitorLocalMovement() {
while (true) {
...
else if (m_PredictionAccuracy > m_PredictionThreshold) {
// Find how far we travelled since the prediction failed
Vector3 localMovement = m_LocalBufState[j].pos - m_LocalBufState[0].pos;
// "Erase" old values in the local buffer
m_LocalStateCount = 1;
// New position which we need to converge to in the update loop
m_NewPosition = m_BufferedState[0].pos + localMovement;
// Trigger the new position convergence routine
m_FixError = true;
...
}
}
...
void Update () {
double currentTime = Network.time;
double interpolationTime = currentTime - m_InterpolationBackTime;
if (m_IsMine && m_FixError) {
Vector3 difference = m_NewPosition - transform.position;
transform.position = Vector3.Lerp(m_NewPosition, transform.position, difference.magnitude);
...
}
}
}
I am facing with the same kind of question, spending time with no success in understand how Lerpz rotation it's passed/working/corrected on TPS-Auth example. Position looks passed via RPC (as keyboard inputs values), but rotation are not passed via RPC and I don't understand how it is corrected by Gradually Update State. I'am trying to adapt the TPS-Auth example to a FPS-Auth one, but I'am in running in some headaches with rotating the character using mouse. $$anonymous$$aybe the input mouse have to be send via RPC along of keyboard inputs, prior of correction rotation with State Synchronization? If don't use keyboard, Quaternion rot = transform.rotation looks missing point (whatever, nothing about rotation are serialized ) since we don't have any RPC about rotation. Processing and correcting rotation maybe it's a lot more complicated. I am deeply lost in understanding this schema.
I haven't been working on this since the end of my summer vaction. Sorry for the delay. I am gradually revisiting the my project.
First off, approach-wise, using the $$anonymous$$ultiplayer Tutorial resulted in a lot of convoluted code and in the end, it still didn't quite work right. I managed to find a copy of the Zero to Hero Guide and that code was much more concise and it worked immediately. These days, the Zero to Hero stuff is more difficult to find. I think the person that created it now supports Photon Networking.
But I absolutely did have to also pass the rotation data from the server to the client where it overwrote the extrapolated rotation for the object.
I noticed things progressing out of sync, rotation-wise, after slam$$anonymous$$g the vehicle into walls. I think that there is a random element in these collisions that, if handled by both the client and the server, results in things getting increasingly desynchronized. You'll notice your vehicle's facing skewing worse and worse after each crash.
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Help|sync movement in multiplayer 1 Answer
Can you create a Stand alone server for your game? 0 Answers
a child object that inherits only position from parent 2 Answers