How do I sync player's 'equipped' items in multiplayer?

0 favourites
  • 6 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Say I'm building a persistent-world RPG with standard 'paper doll' equipment layered over the base player form. Some of this equipment is merely visual; some of it affects player stats. Generally, I would imagine the best way to store what equipment the player is using is via global variables, since my game will take place non-linearly across a large number of layouts.

    However, that would be a problem when it comes time to connect to another peer and 'go multiplayer'; the host (another player, not a central host) has values of their own for these variables.

    I can imagine two ways of handling this:

    1. Have instance variables on the player object that mirror the relevant data from the global variables upon entering the layout, then copy this information over when the player enters the multiplayer space as a peer.

    2. Transmit only the player's 'user ID'. The host then uses that user ID to contact the central character database and retrieve the relevant stats/information about each player.

    Or perhaps there's a third and better way I haven't thought of yet?

    Let me know what you think of this plan!

    Best,

    Joe

  • I'm also curious about this. I set my items up as sprites though, and they go in itemslots, which are also sprites. I'm a little wary of this setup, as I'm not sure what kind of problems I might run into down the road. I admit its a little odd to keep them as physical objects instead of abstractions.

    Anyway I can see a multiplayer scenario where the host has dozens of ItemSlots, all associated with different players, invisible and not synced with each client. The "paperdoll" sprites, as well as any attacks etc., will of course be synced to each client.

    It seems like only your Option 2 is really secure? It seems like using a player's own data in a multiplayer scenario is likely to be subject to manipulation of some kind.

  • I'm also curious about this. I set my items up as sprites though, and they go in itemslots, which are also sprites. I'm a little wary of this setup, as I'm not sure what kind of problems I might run into down the road. I admit its a little odd to keep them as physical objects instead of abstractions.

    Anyway I can see a multiplayer scenario where the host has dozens of ItemSlots, all associated with different players, invisible and not synced with each client. The "paperdoll" sprites, as well as any attacks etc., will of course be synced to each client.

    It seems like only your Option 2 is really secure? It seems like using a player's own data in a multiplayer scenario is likely to be subject to manipulation of some kind.

    Option 1 can be secure as well as long as you occasionally sanity-check against the saved character data on the server... there are various ways you could 'append' security onto something functional after the fact. Option 1 might be the better bet, though.

    Edit: I worry about setting up your items as sprites, because then that would create all sorts of limits on what you can do with that information; seems easier to set your items as data stored somehow (an array? a series of simple variables?) and then set the item slots to be sprites that display a different image (using animation frames perhaps?) to visually indicate what's in that slot according to the variable it's set to.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For example, you can add variables to player with names "pants_id", "weapon_id" and etc. Sync that variables. And when client connects it creates and pin clothing sprites on other players by checking they id's.

  • I have done this Farsight, but once it syncs all the containers sprites go insane.

    Even after applying the "every tick: move to layer(x)" patch.

  • So this is how Im doing it. Peer variable changes graphic for a blank object pinned to the player. This method displays correctly what object the peer is holding to all other peers.

    Since you are also working on an online game. do you know how to make an object be permanently destroyed. Like if host destroys object then it is not created on peer side when logging in.

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