1
\$\begingroup\$

I'm trying to do multiplayer interpolations with the lidgren network (UDP) but the interpolation is taking longer than expected and the message queue is getting full. It's been a week and I still can't find the issue.

Here's an approximate code:

    private void Update()
    {           
        if (networkUpdates.Count > 0 && CurrentUpdate.Finished)
        {
            var update = networkUpdates.Dequeue();

            CurrentUpdate = NextVesselUpdate;
            NextVesselUpdate = update;

            StartupInterpolation();
        }
    }

    private void StartupInterpolation()
    {
        CurrentVesselUpdate.NextUpdate = NextVesselUpdate;
        StartCoroutine(CurrentVesselUpdate.ApplyUpdate());
    }

    //In the CurrentVesselUpdate class....

    public IEnumerator ApplyUpdate()
    {
        InterpolationDuration = NextUpdate.SentTime - SentTime;
        for (float p = 0; p <= 1; p += (Time.delta / InterpolationDuration))
        {
            ApplyInterpolations(p); //Several lerps here
            yield return null;
            Finished = true;
        }
        ApplyInterpolations(1);//Several lerps here
    }
\$\endgroup\$

1 Answer 1

-1
\$\begingroup\$

OK I finally solved moving the StartupInterpolation() to the fixed update and the other logic to the LateUpdate

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .