Multiplayer & fast-moving bullets...

Get help using Construct 2

Post » Mon May 23, 2016 7:38 pm

I hope someone out there might be able to point me in the right direction here....? I am experimenting with the multiplayer plugin (which is excellent, of course) but I have encountered a limitation (of multiplayer with lag and, possibly, a limitation of my c2 dev skills).

The problem: The host runs all of the bullet collision checks, but the lag experienced by a peer makes host bullet collisions look rather awful (bullets are destroyed before they appear to hit walls) and it can spoil action game-play (bullets appear to hit a peer before the peer sees the hit take place - a peer dodging out of the way can be impossible at high bullet speeds etc). Even with a LAN 60 Hz update rate, the slight lag you can expect has confounded me so far.

I imagine that a way to solve this problem, for hits on inanimate objects at least, would be to check for a collision in the host and then flag a bullet for destruction at a particular X and Y position, before then destroying it when it gets to within a certain range of that position on the peer's machine (effectively a destroy delay). For hits on moving peers, I imagine that a similar flag would be required (although I am not sure what, if any, lag compensation might be required here).

I have an aspiration to making an action platformer, but I am not sure that the physics limitations of even a LAN can be accommodated effectively. Before I embark on trying to make this work, I would be grateful for any advice for alternative methods and if anyone has any lessons they would like to share regarding solving this problem.

Thanks!
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,188

Post » Mon May 23, 2016 7:48 pm

plugin-jcw-trace-raycast_t172320

There is no bullet......
Image ImageImage
B
168
S
50
G
163
Posts: 8,224
Reputation: 105,067

Post » Mon May 23, 2016 7:56 pm

Here's an example of what it looks like:

Shooting as the host:

Image


...and being shot, as a peer:

Image
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,188

Post » Mon May 23, 2016 7:58 pm

Thanks @newt - I love that raycasting plugin but I don't see how to effectively use it in this case. I think I needed to post the gifs first...
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,188

Post » Mon May 23, 2016 8:19 pm

First of all don't use the bullets collision.
Second don't make the hit effect at the collision, do it at the target.
You get the distance of expected collision from the raycast, and time it that way.
If a bullet moves at 1 pixel a second, and the object is 10 pixels away you would destroy the bullet after 10 seconds... given it has constant speed.
Likewise for the object being hit. In fact I would say it's more important to time it's fake collision than it would be for the bullet, since bullets frame skip a lot anyway.
#timerbehavior
Also the bullet behavior has a distance method, but I think timing would be better here.
Image ImageImage
B
168
S
50
G
163
Posts: 8,224
Reputation: 105,067

Post » Mon May 23, 2016 8:39 pm

Thank you @newt - that's some really good advice. Back to the drawing board for me, then, but in a good way...
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,188

Post » Mon May 23, 2016 9:01 pm

It's not too bad.
You just have to send the client the time,and the id of the target.
Image ImageImage
B
168
S
50
G
163
Posts: 8,224
Reputation: 105,067


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 11 guests