Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 949351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:23:24+00:00 2026-05-15T23:23:24+00:00

I am experimenting with lidgren in XNA and I’m having some issues with the

  • 0

I am experimenting with lidgren in XNA and I’m having some issues with the ‘lag’.

I’ve downloaded their XNA sample and noticed that even their sample lags. The thing is, the movement is not smooth on the other side, and I’m trying this on a LAN (on the same computer actually) not over the internet.

Has any had the same issues as regards unsmooth movement due to a lagging connection with lidgren and XNA ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:23:25+00:00Added an answer on May 15, 2026 at 11:23 pm

    The sample you linked directly sets the position to whatever it receives from the network, this is a bad idea for a multiplayer game!

    What you should do in a real game is interpolate between the local position and the remote position. So, your receive method would look a little like this:

    void Receive(packet)
    {
        unit.RemoteX = packet.Read_X_Position();
        unit.RemoteY = packet.Read_Y_Position();
    }
    

    This has no affect on the local position on the unit, instead in your update method (every frame), you move the local position towards the remote position:

    void Interpolate(deltaTime)
    {
        difference = unit.RemoteX - unit.LocalX
        if (Math.Abs(difference) < threshold)
            unit.LocalX = unit.RemoteX
        else
            unit.LocalX += difference * deltaTime * interpolation_constant
    }
    

    You then display the "local" position of the unit, this achieves lagless movement like so:

    1. If the unit position is almost at the remote position, it will jump to the remote position (however, it will jump such a tiny distance that it won’t look laggy).
    2. If the difference is too big to jump, then move slowly towards the position you should be in.

    Since the unit moves smoothly towards where it should be, it looks like there is no lag at all!

    The interpolation constant controls how fast the local and remote positions will converge:

    • 0: Ignore network updates
    • Small: Snap into place very quickly (possibly look laggy)
    • Large: Slide slowly into place, looks smooth but may feel unresponsive

    You need to choose a compromise somewhere in between these options.

    There are some other things to consider when implementing this kind of system, for example you often want an upper limit on how far apart units can be from their remote position otherwise the local and remote state can become "unstuck" in some situations. If they are too far apart (which should never happen except in cases of extreme lag) you can either halt the game and tell the user it’s too laggy, or jump the unit straight into position, which will look laggy but at least the game will continue.

    Addendum: Rereading this answer, it occurs to me that an enhancement would be to track time differences. If you know (roughly) what the lag is in the system, then you know that when you receive a packet with a remote position in you know roughly how far into the past that packet is from. If you send remote velocity too, you can predict where the object is now (assuming constant velocity). This may make the difference between estimated local state and true remote state smaller in some games, in other games (where you have lots of changing velocities) it might make things worse.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When experimenting with (embedded) Apache Derby DB, I noticed that a fresh database, with
While experimenting with this question on collections in Spring.NET , I discovered that Spring
While experimenting with pixel shaders in WPF I decided to draw some pixels onto
I'm experimenting with Linq and am having trouble figuring out grouping. I've gone through
While experimenting with some stuff on the REPL, I got to a point where
Experimenting with Cocos2D collection detection and have some questions. First, some background: This is
Experimenting with new features of T-SQL, I've run into a puzzle. Here is some
Just experimenting and learning, and I know how to create a shared dictionary that
I've been experimenting with the standard python math module and have come across some
I'm experimenting with internationalization by making a Hello World program that uses properties files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.