Multiplayer, Lag Compensation

Discussion and feedback on Construct 2

Post » Thu Jul 09, 2015 8:00 pm

OK, so I am really trying to wrap my head around Lag Compensation in Multiplayer.

I'm hoping someone on the forums with a good handle on this can shed some light on it.

So I created a 2 player Arkanoid type game, here is a screen shot to give you an idea:
Image

Everything works great, except many times the peer will think he hits the ball, but misses it. Why? Because of lag.

Now in the Ghost Shooter MP Tutorials (MP Tutorial 4) the way Ashley does lag compensation makes sense. The firing of a bullet is instantaneous, there is no movement too it. However, in my case there are bouncing balls that are moving. Maybe it's the same thing as. I just can't figure out how it's the same.

What would be a way to approach this? My brain is really struggling on this.
Should I be checking on the ball overlapping the paddle instead and then forcing the bounce action? Should I have an invisible sprite that is on the same X path as the paddle and when the ball collides with that, check for a lag compensated value of the paddle.x to see it was in the right place?

Thanks all.
B
101
S
32
G
11
Posts: 1,552
Reputation: 21,667

Post » Thu Jul 09, 2015 8:11 pm

Might I ask how you determine ball movement on peer end ?
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Thu Jul 09, 2015 8:32 pm

Bullet Behavior, from the host side.

I'm happy to share the Capx if you think it would help.
B
101
S
32
G
11
Posts: 1,552
Reputation: 21,667

Post » Thu Jul 09, 2015 9:45 pm

First off, I am not sure the lag compensate mechanic is applicable to this situation.
It seems to me the required mechanic here relies on knowing where a paddle/ball might be, in stead of having to know where it was.

But, seeing as there is a level of predictive-ness involved in the plugin, it might apply.

I have not made a mechanic like this yet, but I would start by trying:

if the ball passes a certain Y , on either end where it crosses a line where it 'could' interact with a peer's paddle, I would perform a quick lag compensated X,Y on the peer's paddle, check for collision with the ball, then return paddle to original position.


Remember, only the host can perform the lag compensate re-positioning. So if the host deemed it a collision, it will perform the actual collision.
Right after, you replace the paddle back to its original position, but it will have performed the bounce if that is already in the host mechanics. (and if it really works :lol:)



I always envision the lag compensate test as a method to determine a connected users position (either host or peer), a moment in the past based on the lag time from a peer(!not host).
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Thu Jul 09, 2015 9:51 pm

I'll give that a shot, thank you.

Any chance you can explain a bit better what movingPeerID and fromPeerID are?
LagCompensateX(movingPeerID, fromPeerID)

Would movingPeerID be the paddle and fromPeerID be the ball in my case?
B
101
S
32
G
11
Posts: 1,552
Reputation: 21,667

Post » Thu Jul 09, 2015 10:06 pm

The moving peer id would be the peers paddle, and seeing how the host needs to determine when/where, the frompeerid would be the host.

EDIT: this is a bit of a problem, as that would rely on knowing where something was.
This makes me think it will not work.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Thu Jul 09, 2015 10:48 pm

I'll give it a try. You would think doing something as simple as a pong type interface, shouldn't be too hard. But even with the pong example, you can see the issue as it has no lag compensation implemented.
B
101
S
32
G
11
Posts: 1,552
Reputation: 21,667

Post » Thu Jul 09, 2015 11:14 pm

OK, I added a sprite box and then added this code. Also on connection of peer I am simulating a latency (default settings). I didn't seem to make a difference. Peer paddle still misses when it shouldn't.

Image

New code in red.
Image
B
101
S
32
G
11
Posts: 1,552
Reputation: 21,667

Post » Fri Jul 10, 2015 5:29 am

Ah, you missed the concept here:

events I proposed should look like:

example for player at the top of screen, Lets call this paddle peerA


event:
Ball.Y < 50
-subevent: PeerA.peerid <> multiplayer.hostid
-action: set oldx to peerA.x
-action: peerA set X to lagcompensateX(PeerA.peerid, multiplayer.hostid)
--subevent: Ball is overlapping paddle
--subevent: peerA set x to oldx
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Fri Jul 10, 2015 5:31 am

I'll give that a shot.

What does <> mean?

Thanks for the help!
B
101
S
32
G
11
Posts: 1,552
Reputation: 21,667

Next

Return to Construct 2 General

Who is online

Users browsing this forum: ugurtufekci, Yahoo [Bot] and 2 guests