Smoothing Out Multiplayer Movement

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Sammm
Prole
Posts: 37
Joined: Fri Sep 09, 2022 4:39 pm

Smoothing Out Multiplayer Movement

Post by Sammm »

Hello! I've created some basic multiplayer movement code, but right now everything looks super jittery. My code to draw clients is basically just:

Code: Select all

for k, v in pairs(server.playerData) do
	love.graphics.circle("fill", v.x, v.y, 50) -- Draw player graphic exactly at position
end
I'm using a physics engine so I can't simulate the client in real time, since everything that moves is variable. I just need to figure out how to add some basic interpolation or something so that the movement of other clients and entities can be smoothed out. I've looked for a ton of sources already but everything I saw uses Unity or has some long winded approach that I believe is overkill for such a simple game I'm creating (a 2D platformer dodge game). If someone could perhaps demonstrate some simple pseudo code or at least point me in a reasonable direction to go forward with implementing this, I would greatly appreciate it!
Lua is LÖVE, lua is life
User avatar
Bobble68
Party member
Posts: 162
Joined: Wed Nov 30, 2022 9:16 pm
Contact:

Re: Smoothing Out Multiplayer Movement

Post by Bobble68 »

I will admit I haven't messed around with multiplayer much, but I could give some suggestions. My first instinct is to record its last known position and speed, and just use that to guess its next positions linearly until you get the next position to correct it. I think that should make it less jittery, though in some circumstances it might look odd.
Dragon
User avatar
dusoft
Party member
Posts: 635
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Smoothing Out Multiplayer Movement

Post by dusoft »

Sammm wrote: Tue Aug 08, 2023 10:21 pm Hello! I've created some basic multiplayer movement code, but right now everything looks super jittery. My code to draw clients is basically just:

Code: Select all

for k, v in pairs(server.playerData) do
	love.graphics.circle("fill", v.x, v.y, 50) -- Draw player graphic exactly at position
end
I'm using a physics engine so I can't simulate the client in real time, since everything that moves is variable. I just need to figure out how to add some basic interpolation or something so that the movement of other clients and entities can be smoothed out. I've looked for a ton of sources already but everything I saw uses Unity or has some long winded approach that I believe is overkill for such a simple game I'm creating (a 2D platformer dodge game). If someone could perhaps demonstrate some simple pseudo code or at least point me in a reasonable direction to go forward with implementing this, I would greatly appreciate it!
Maybe tweening between position A and position B? This could also look weird. But if you allow movement only in certain directions, then also approach suggested above, taking direction and speed in account, could work.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 1 guest