Complicated Multiplayer Question

0 favourites
  • 5 posts
From the Asset Store
The official Scirra Multiplayer Signalling Server for helping peers find and connect to each other
  • Hello,

    I'm creating an MMO. Currently the players are represented by Peer Objects as in the Multiplayer Tutorials

    I'm wondering what the best way to add in NPCs is. There is a lot of logic already built specifically into the Peer objects, so these NPCs would ideally be Peer objects without players on the other end and run off the same logic already used for Players, simply by changing their "input" variable using host AI instead of keyboard inputs

    This is the big question I have:

    Is there a way to check, on creation, if a peer object was NOT made by a connecting player? This would prevent Players from treating newly created NPC Peers with their Multiplayer peerids (which they don't have) and would allow me to initialize the NPCs and Players differently

    Tagged:

  • Yes, but the peers use "On Peer created" to initialized players

    I'm looking for a way for the Peer to tell whether or not the Peer that was just created is a Player or an NPC

  • My first approach would be to have all npcs created and handled by the host, with their own events. Copy whatever events you need to initialize them and set up their behaviors. Smart use of functions will allow some event logic to be used by both peers and hosts, but it's generally best to keep them separate.

    To answer your question specifically, you can set a flag/variable during an on peer connected event to signal that the peer object is being created for a player. Otherwise, you can use on peer object created (with the condition flag = false) to differentiate for npcs.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • My first approach would be to have all npcs created and handled by the host, with their own events. Copy whatever events you need to initialize them and set up their behaviors. Smart use of functions will allow some event logic to be used by both peers and hosts, but it's generally best to keep them separate.

    To answer your question specifically, you can set a flag/variable during an on peer connected event to signal that the peer object is being created for a player. Otherwise, you can use on peer object created (with the condition flag = false) to differentiate for npcs.

    So you're suggesting I use a synced variable to check if newly created Peer Objects are NPCs or players?

  • Ahh I just realized I can use "On Peer Connected" in the peer logic rather than "On Peer Created"

    Thanks for your help! This will work

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