Multiplayer Issues

I’m making multiplayer game, but when I try it with another device, the other device’s screen is gray, so player 2 can’t see the screen. Is this supposed to happen?

1 Like

Hmmm … interesting! I tried all of the tricks that I could think of, but I couldn’t get it to work, either.

Symptoms

  • Multiplayer environment works correctly within editor.
    • Can switch among players.
    • Both players can interact with game.
  • Multiplayer environment outside of editor does not work correctly for this game.
    • Host player can initiate game.
    • Other player(s) can join via link.
    • When host starts game, host display is correct.
    • When host starts game, other player(s) screen goes gray and does not update.
    • Host player receives events from other player(s), so host can see other players interacting with the game (e.g., players sprites can move, fire, and jump in response to their controls).
  • No obvious errors appear in the browser’s JavaScript console when running the multiplayer environments.

Correction attempts

  • I noticed extensions are added to this project that aren’t currently used. I removed all of the unused extensions, thinking one of them does not work well (yet) with multiplayer. I started by focusing on the extensions that have anything to do with screen updates or the camera.
  • I noticed the camera was set to follow two different sprites. Removed the extraneous block.
  • Added a blank on update container, thinking that might force the screen to update. (Silly, I know, but I was throwing everything at the wall to see if anything would stick!)

The multiplayer environment definitely works, as there are many games on the MakeCode Arcade home page that work just fine. There are a bunch of other things that I could try, but my current thinking is this: I think one of the extensions that you are using is causing some sort of interaction with the multiplayer environment.

How I will proceed with my continued tests will be to start a new project with a bare minimum of your code, ensuring that it works within the multiplayer environment. Once I have a starting point that works, then I will add code back into the project a little bit at a time until it breaks. If it breaks, then we have identified an element that does not work with multiplayer, and we can diagnose from there. If it does not break, then you will have a working project from which you can continue to build.

I won’t have time today to do this, but I will revisit this later in the week. Feel free to give it a try yourself and see if you can figure out what part of your program is breaking the multiplayer environment.

Setting screen dimensions by setting userconfig is very much an ‘experimental’ feature – it’ll work in the simulator, but it doesn’t apply to hardware, we don’t really have many guarantees on it working with existing systems, etc.

In the multiplayer implementation, to make sure arbitrary games can work without any custom logic being implemented to handle networking, the screen is mirrored over from the host to the clients. This does not handle the screen dimensions written in userconfig, and really can’t support arbitrary dimensions – e.g. if we were to use the same logic for this game, it would need about 200kb/per frame, or something like up to 6megabytes per second / per player, which would be WAY too much to sustain. This might be something we can consider to some degree if we add server hosted games to support multiple cameras, but is not something we can support at this time – local multiplayer only unfortunately :frowning:

2 Likes

I believe the problem was your screen width and height modifier. I’m not sure why, but I think it was messing the player 2 camera up.

I saw that block and didn’t realize what it was, @jwunderl . Thanks for that information!

Got it. Thanks!

Very helpful. I was able to shorten my code. thanks!

1 Like

is there any way to fix this issue?