# Current Controller in Multiplayer

**URL:** https://forum.makecode.com/t/current-controller-in-multiplayer/29548
**Category:** Help
**Created:** [July 3, 2024, 6:01pm UTC](https://forum.makecode.com/t/current-controller-in-multiplayer/29548 "2024-07-03T18:01:29Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Kikketer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikketer/32/16551_2.png) [@Kikketer](https://forum.makecode.com/u/Kikketer)
#### Post date: [July 3, 2024, 6:01pm UTC](https://forum.makecode.com/t/current-controller-in-multiplayer/29548/1 "2024-07-03T18:01:30Z")

</div>

In my current attempt I’d like to have each player see different items. Think of a simple poker style game where each connected player sees their own hand and no one elses.

I’ve dug around and I really can’t find a way to say “current controller”. From what I’ve gathered all of the code is global and shared across all players. So right now I have an object assigned to each player as they are connected:

psudo code:

```auto
on connect: player -> { cards: [], controller: getControllerBasedOnIndex(player.index) }

```

The above psudo code simply creates an array of players, each with some meta-data around their assigned controller. The controller is figured out `controller.player1` etc based on the `player.index` but there’s no way I can figure out which player index (or controller) the current player is!

I can see the current implementation of multiplayer says that “all players control a sprite at the same time” which works well for “everyone sees the same screen” but there doesn’t seem to be a way to say “you are player 2, show only player 2 items”.

Ideally when I click the different player icons in the simulator, the screen will change to that players view. But without the ability to say “the current player is X” it’s impossible to do any specific logic based on who you are.

---

<div class="post-metadata">

### Author: ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)
#### Post date: [July 3, 2024, 6:43pm UTC](https://forum.makecode.com/t/current-controller-in-multiplayer/29548/2 "2024-07-03T18:43:39Z")

</div>

Welcome, @Kikketer !

Separate screens for each player in a multiplayer setup is something up for consideration in future versions of MakeCode Arcade. It is not available in its current version.

Follow and comment on this issue in GitHub:

> <https://github.com/microsoft/pxt-arcade/issues/5113>
>
> \* For online multiplayer, support different camera views for each player.
> \* For… local multiplayer, this would render as split view
> 
> This feature would allow players to individually roam a large tilemap.
> 
> TODO: define how a game should indicate it wants this behavior
> \- Is it a game setting/checkbox?
> \- Could it be implicit from the blocks present in the program?
> \- Should it be an explicit camera mode block, e.g. "multiplayer camera mode \[same screen|own screens\]"

---

<div class="post-metadata">

### Author: ![Kikketer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikketer/32/16551_2.png) [@Kikketer](https://forum.makecode.com/u/Kikketer)
#### Post date: [July 4, 2024, 2:30am UTC](https://forum.makecode.com/t/current-controller-in-multiplayer/29548/3 "2024-07-04T02:30:34Z")

</div>

Thank you. I’ll keep an eye on it.  
I have dreams of having two devices with their own views, but I can see how this would become troublesome if you need to support two views on a single screen.

Given the nature of two screens already when you share links and two physical devices for the hardware option. I would think a simple “who’s active” type of step would be a reasonable first step.

---

<div class="post-metadata">

### Author: ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)
#### Post date: [July 4, 2024, 2:39am UTC](https://forum.makecode.com/t/current-controller-in-multiplayer/29548/4 "2024-07-04T02:39:25Z")

</div>

The hardware solution may be the easier of the two to accomplish, although I don’t recall where we are regarding the interconnect messaging software.[1] Separate “screens” via network multiplayer is a much taller order, but the MakeCode team loves working on challenging problems. 🙂 It’s on the back burner, but the pot is always simmering. Stay tuned.

* * *

[1] MakeCode Arcade has supported Jacdac in a variety of incarnations, but I haven’t seen anything new on that front in a while.

---

<div class="post-metadata">

### Author: ![Kikketer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikketer/32/16551_2.png) [@Kikketer](https://forum.makecode.com/u/Kikketer)
#### Post date: [July 5, 2024, 4:22pm UTC](https://forum.makecode.com/t/current-controller-in-multiplayer/29548/5 "2024-07-05T16:22:57Z")

</div>

Jacdac is exactly where I’m looking now and it may actually fit the bill (if I can figure it out).  
Seems the jacdac project mostly focuses on attaching external devices, not so much two meowbit style controllers directly.

However I did find this github issue: [https://github.com/microsoft/jacdac/issues/1308](https://github.com/microsoft/jacdac/issues/1308) that appears to attempt to do what I’m thinking. Any maybe this worked as a pure jacdac connection before the multiplayer addition? Right now jacdac doesn’t seem to have an easy way to directly connect two meowbit controllers directly at least out of the box…

---

<div class="post-metadata">

### Author: ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)
#### Post date: [July 5, 2024, 4:33pm UTC](https://forum.makecode.com/t/current-controller-in-multiplayer/29548/6 "2024-07-05T16:33:10Z")

</div>

This thread might be of interest to you.

> [@Hardware Multiplayer (game)](https://forum.makecode.com/t/hardware-multiplayer-game/132):
>
> Hey folks, For those lucky enough to get their hands on some Arcade hardware (by GHI or Kittenbot) here’s a sample that shows how to do multiplayer between devices! To play the game, load the UF2 on two devices and connect them via the headphone jack. Please note that the APIs I use here are subject to change. Also, this game cannot be played in the simulator right now (hardware only). Want to learn more about how it works? Check out JACDAC at [https://jacdac.org/](https://jacdac.org/) and our recent blog post [ht…](https://makecode.com/blog/ozette/ozette)

It’s ancient, so don’t expect any of the code to work, but it might serve as inspiration. Fundamentally, Jacdac hasn’t changed since then, but I know the APIs have changed.

---

<div class="post-metadata">

### Author: ![Kikketer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikketer/32/16551_2.png) [@Kikketer](https://forum.makecode.com/u/Kikketer)
#### Post date: [July 5, 2024, 5:14pm UTC](https://forum.makecode.com/t/current-controller-in-multiplayer/29548/7 "2024-07-05T17:14:16Z")

</div>

Ooh this may be helpful, thank you!

---

<div class="post-metadata">

### Author: ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)
#### Post date: [July 9, 2024, 5:57pm UTC](https://forum.makecode.com/t/current-controller-in-multiplayer/29548/8 "2024-07-09T17:57:37Z")

</div>

@Kikketer feel free to ping me if you run into trouble! I can direct any questions to the right jacdac folks 🙂

---

<div class="post-metadata">

### Author: ![Kikketer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikketer/32/16551_2.png) [@Kikketer](https://forum.makecode.com/u/Kikketer)
#### Post date: [July 11, 2024, 2:35am UTC](https://forum.makecode.com/t/current-controller-in-multiplayer/29548/9 "2024-07-11T02:35:26Z")

</div>

Thanks a ton. I wandered through that link and some of the discussion in there. I decided that the jacdac was a little too complicated for me and just ordered up the mewbit wireless sd card.

This is outside the original topic of “Current Controller”, I’ve decided to build two games:

- One that has multiplayer but sharing the same screen (side scroll beat-em-up) - This will be web based and use the new multiplayer blocks (which are awesome btw)
- One that simply transmits some game state information but run independently on two different meowbits using the sd card … so “multiplayer” but not using the multiplayer blocks

Excited to see how these turn out.
