How do I safely switch layouts when using the Multiplayer plugin?

Not favoritedFavorited Favorited 1 favourites
  • 4 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hi,

    I'm making a multiplayer game (using Construct's Multiplayer plugin) and the engine seems to freak out about destroying synced objects when I try to switch layouts. My guess is that basically if they are not switched exactly at the same time, the engine has a hard time keeping the same amount of sync objects created on host and peers. What is the intended way of changing layouts for Multiplayer plugin games?

    Thanks!

  • Hey.

    Just a reminder for if anyone reads this that this is not solved and I really need a response so I can continue work on this project.

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The straight answer is to not use the multiplayer sync action when changing layouts, and handle object syncing manually via messaging. This works best for peers being able to wander across layouts locally, you wouldn't necessarily need to sync objects for everyone in the first place. Messages and rooms persist across layouts.

    Alternatively, depending on what you're using layouts for, you might be able to design around using layouts in the first place. Are you using them for memory management? Is everyone changing layouts with the host or separately?

    Another idea (I have not tried this, but it might be the cleanest way) is to use a new signaling room, while staying connected to the signaling server. The host will indicate to peers to leave room, and the new destination room. The host waits until everyone has left, then leaves and creates the new room, on the new layout at the previously designated room id. Peers wait until the room exists before joining (host gets in first) via request room list and on room list. PeerID's should persist, as well as global variables and objects on the host. Well basically everything on the host persists. This is similar to host migration on lost connection, but a little simpler, since the host remains the same.

    A further option is to not use the multiplayer plugin, and to use a server/client design with a third party tool, which isn't really the answer to your question, but can solve a lot of these types of problems.

  • oosyrag to the rescue, as always.

    Thank you for the reply, first of all.

    In my game, everyone will be switching layouts at the same time, to the same layout. Layouts are maps for each round to be played in. So, any specific ideas?

    You've already given me plenty to try anyway, thank you. I'm also thinking maybe I could make all synced objects persist thru layouts then manually destroy them on host, I think this would avoid exceptions.

    Edit: I just realized that the persist behavior isn't what I thought it was. I thought it made objects not be destroyed when changing layouts, for some reason.

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