How do I make multiplayer moving platforms

0 favourites
  • 7 posts
From the Asset Store
A pack of 76 platform designs for a platformer game with a mushroom/jungle theme
  • So I've been working on networking a platforming game, and I've seen some unusual behavior, specifically with how the the second player interacts with moving platforms.

    The server is perfect, it always gets everything right.

    On the client side the second player sways back and forth while on a moving platform that goes side to side. In extreme cases this can cause the player to fall off the platform on the client's side, but not on the server side, therefore causing a frantic desync interpolation fix fairly quickly.

    When on a platform that goes up and down it doesn't display jumping correct most of the time, and this can lead to the player jumping onto a platform on the server side, but not on the client side. The client side tries to fix this desync error by moving the player up, while gravity's pulling it down, so when the player's actually on a platform the client sees them self hovering below the platform.

    These problems increase if I "simulate lag" by a fair margin. These problems both sound like the moving platforms are not accounting for lag between the server and client, but as I'm using the platform behaviour, I do not know when to do lag compensation on the platforms to make the client and server sync up nicely.

    Here's a version of my .capx

    [attachment=0:360nubhk][/attachment:360nubhk]

  • Interesting topic.

    Ashley

    I also work on a multiplayer platformer now and have a lot of issues. I think platform behavior doesn't fit into multiplayer concept (host/peer) at all. If you enable local input prediction for a peer, there will be constant position glitches etc. Without input prediction and platform behavior enabled on peer's side it's not possible to play, because the delay between peer's input and response is very noticable.

    A bit off-topic: an official pong example stops working correctly after certain ball speed. So there's some room for improvement for real time multiplayer.

  • Robsta - The best way I found to do this so far is to synchronize instructions instead of objects for multiplayer platform based games. Its bit more complicated but I call functions cross device to achieve this. Here's a working example of a multiplayer platform using functions. Maybe you can adapt it to your project if you like how it works.

    Open a few browser windows, click connect on each and then use arrows to move.

    [attachment=0:pwgnwr68][/attachment:pwgnwr68]

  • troublesum I spent some time over looking over your code, and I see what you're doing. This is a much more hands on approach the the default multiplayer, and it works quite well in the example, but what you appear to be doing is circumventing a some of the functionality of the multiplayer plugin. Here's how:

    You're getting around the problems with desync compensation by just teleporting the object to the location it's supposed to be. While this does fix some of the problems I mentioned above (with the desync compensation leaving the player floating), it however can look jerky at times, especially since it only syncs position when the player stops moving (this includes at the top if they're jump!).

    You fix the problem of the player not seeing the correct events happen by letting the player decide where they are and send it to the host. I like this in that it's the player who needs to see what they're doing, in order to make informed decisions about what to do next. I don't like however, That this means the host doesn't have an accurate representation of where you are, and thus it's just transferring the problem from the player to the host. This might be fine in a cooperative game like I'm hoping to make, but I never would want to do it in a competitive game where this would make it possible to hack.

    It doesn't appear to do too well with lag. Sure no multiplayer options do too well with lag, but without a smooth desync compensation it looks to me to be just a little jerkier then the basic multiplayer plugin's sync option.

    So in conclusion, thank you for the example, I may take some ideas from it and implement it, for example I do like how you force-teleported without desync compensation sometimes, so I might use that. But I don't think I'll do this for everything in the game.

  • Robsta If it helps you in any way then im glad... ... yah i have since changed how i coordinate instructions (I since turned this into a plugin also, so its all done with a single line now) but i now i set position prior to every move instruction and don't update position every 30 ticks anymore. This reduced jerkiness as you described and aided in syncing being more accurate. Also as long as the host is the only entity validating events like when a player is hit then its less prone to hacking. Just because a peer sees something get hit doesn't mean it actually happened. Only if the host sees it will the host then call a function to indicate a hit for all peers. Host controls all game metrics and events always. Players just move them selves and tell the host what they are doing. (The example doesn't reflect this very well as its just showing movement with out any game events). In any case if you have any questions about this method I'm happy to help.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Just wondering if anyone else had ideas, preferably ones that didn't require a what is effectively a manual rewrite of part of the multiplayer object.

  • I'm stuck on this also, whenever the peer moves it can be a little buggy. Sometimes when the peer goes to jump he just shakes and sits there. Anyone have any ideas?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)