Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
plugins: [
'@babel/plugin-transform-modules-commonjs'
]
};
29 changes: 29 additions & 0 deletions blog/2021-04-07-boss-room-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Boss Room docs are live!
author: Lori Krell
author_title: Unity, Senior Tech Writer
tags: [releases, bossroom]
description: Welcome to the first release of the Unity Multiplayer Samples Co-op documentation content. Learn more about Unity MLAPI through the sample co-op Boss Room game and project.
hide_table_of_contents: false
---

You [saved the date](https://unity.com/demos/small-scale-coop-sample), and now Boss Room is public and live!

Boss Room leverages the new experimental netcode package to bring up to eight players together to defeat imps and a boss in this adorable vertical slice of a cooperative RPG dungeon. This small-scale cooperative game is built to teach you the underlying networking patterns and concepts behind a multiplayer game of its genre.

The Boss Room project equips you with all the project files and assets you need to explore the creation of a small-scale cooperative game packed with playable characters, enemies, and a boss. As Boss Room is being developed, tutorials on the different aspects of networking the sample will be written for developers right here on our live documentation site – so stay tuned!

![Boss Room](/img/blog/boss-room.png)

To support this release, we provide getting started, tutorials, release notes, and more!

* [Multiplayer Samples Co-op Release Notes](/docs/release-notes/samples/samples-0-1-0)
* [Getting started with Boss Room](/docs/learn/bossroom)

Visit and ⭐️ the Unity Multiplayer Samples Co-op [GitHub repository](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop) to watch for updates, provide feedback, and contribute to the project.

When downloading, always get the [latest from GitHub](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/releases/latest).

If you have questions and want to connect, check out the Unity Multiplayer forum or join us on [Discord](https://discord.gg/buMxnnPvTb). We have channels for announcements, support, development, and co-op samples.

Game on!
23 changes: 23 additions & 0 deletions docs/learn/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,27 @@ We recommend the following:

The Steam transport should be quite straightforward to use. Just add it to your project and set the `ConnectToSteamID` in the transport on the client to connect to the host that's all you need.

### Why do I get path too long errors with Boss Room on Windows?

Using Windows' built-in extracting tool may generate an "Error 0x80010135: Path too long" error window which can invalidate the extraction process.

As a workaround, shorten the zip file to a single character (for example "c.zip") and move it to the shortest path on your computer (such as in root C:\) and retry. If that solution fails, another workaround is to extract the downloaded zip file using an application like 7zip.

### Why do I get unidentified developer errors with Boss Room?

If you attempt to run a build on OSX and receive a warning dialog mentioning an "unidentified developer", you may need to override your security settings for this application:

1. In the Finder on your Mac, locate the application you want to open.

:::note
Do use Launchpad, it does not allow you to access the shortcut menu.
:::

1. Control-click the app icon, then choose **Open** from the shortcut menu.
1. Click **Open**.
1. The app is saved as an exception to your security settings. You can open it in the future by double-clicking it just as you can any registered app.


See [Apple Support](https://support.apple.com/guide/mac-help/open-a-mac-app-from-an-unidentified-developer-mh40616/mac) for details.

</div>
63 changes: 37 additions & 26 deletions docs/learn/getting-started-boss-room.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,65 +13,62 @@ Boss Room is a fully functional Multiplayer Co-op Sample game made with Unity an

The intention is that you can use everything in this project as a starting point or as bits and pieces in your own Unity games.

## To get the project
## Get the project

### Install Git LFS
This project uses Git Large Files Support (LFS), which ensures all large assets required locally are handled for the project. See [Git LFS installation options for Windows and Mac instructions](https://github.com/git-lfs/git-lfs/wiki/Installation).

### Get the Project
### Get the project files

- A release version can be downloaded from the [Releases](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/releases) page.
- Unzip the archive file.
- A release version can be downloaded from the [Latest Releases](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/releases/latest) at GitHub.
- Unzip the archive file.
:::note Windows users
Using Windows' built-in extracting tool may generate a "Error 0x80010135: Path too long" error window which can invalidate the extraction process. A workaround for this is to shorten the zip file to a single character (eg. "c.zip") and move it to the shortest path on your computer (most often right at C:\) and retry. If that solution fails, another workaround is to extract the downloaded zip file using 7zip.
Using Windows' built-in extracting tool may generate an "Error 0x80010135: Path too long" error window which can invalidate the extraction process. As a workaround, shorten the zip file to a single character (for example "c.zip") and move it to the shortest path on your computer (such as in root C:\) and retry. If that solution fails, another workaround is to extract the downloaded zip file using an application like 7zip.
:::
- You are now ready to add the project to Unity Hub.
- You are now ready to add the project to Unity Hub.

:::important Compatibility
- Boss Room supports all major Unity platforms. To use the WebGL platform a custom WebGL transport based on web sockets is needed.
- Boss Room is compatible with Unity 2020.3 LTS and later.
- Boss Room is compatible with Unity 2020.3 and later.
- Make sure to include standalone support for Windows/Mac in your installation.
:::

## To add the project with Unity Hub
## Add the project with Unity Hub

1. Open Unity Hub.
1. Click **Add**.
1. Select the root folder of the downloaded project.

![adding project to unity](/img/addbossroom.gif)

:::note
The first time you open the project Unity will import all assets, which will take longer than usual - it is normal.
The MLAPI v0.1.0 package will be installed with Boss Room.
The first time you open the project, Unity will import all assets, which will take longer than usual - this is normal. The Unity MLAPI v0.1.0 package will also be installed with Boss Room.

**Issues with importing due to parental control software**: If you have issues with importing you may want to check your DNS settings as some ISP parental controls may block GitHub access. For example, see this information on [WebSafe](https://community.virginmedia.com/t5/Networking-and-WiFi/Web-Safe-Breaks-GitHub/td-p/4279652).

:::

## Open the project

### To open the project for the first time:
To open the project for the first time:

1. In Unity Hub double click the project.
1. In Unity Hub, double-click the project.
1. Navigate to the Project window.
1. Open the *Assets* folder.
1. Open the *Scene* folder.
1. Click the *Startup* scene.
1. Click **Play**.
1. Click **Play**.


<iframe src="https://www.youtube.com/embed/OSSBWOJq6gI?playlist=OSSBWOJq6gI&loop=1&&autoplay=0&controls=1&showinfo=0&mute=1" width="854px"
height="480px" className="video-container" frameborder="0" position="relative" allow="accelerometer; autoplay; loop; playlist; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>



## Test multiplayer
## Test multiplayer

In order to see the multiplayer functionality in action, you can either run multiple instances of the game locally on your computer or choose to connect through the internet.

### Local multiplayer setup

#### Build an Executable.
#### Build an Executable

1. Click File.
2. Click Build Settings.
Expand All @@ -82,11 +79,10 @@ In order to see the multiplayer functionality in action, you can either run mult
After the build has completed you can launch several instances of the built executable to be able to both host and join a game.

:::important Mac Users
To run multiple instances of the same app, you need to use the command line.
To run multiple instances of the same app, you need to use the command line:
`> Run open -n BossRoom.app`
:::


<iframe src="https://www.youtube.com/embed/27Ikr0t7vzg?playlist=27Ikr0t7vzg&loop=1&&autoplay=0&controls=1&showinfo=0&mute=1" width="854px"
height="480px" className="video-container" frameborder="0" position="relative" allow="accelerometer; autoplay; loop; playlist; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>

Expand All @@ -96,22 +92,37 @@ To run multiple instances of the same app, you need to use the command line.
In contrast to running a local setup, when playing over internet we do not necessarily need a built executable. You can run the game in editor.
:::


Running the game over internet currently requires either setting up a [Photon Transport for MLAPI](https://github.com/Unity-Technologies/mlapi-community-contributions/tree/master/Transports/com.mlapi.contrib.transport.photon-realtime) or using Port Forwarding
Running the game over internet currently requires either setting up a [Photon Transport for MLAPI](#photon-transport) or using [Port Forwarding](#port-forwarding).

#### Photon Transport

Photon Transport uses Photon relay server to facilitate communication between clients and server living on different networks.

[Photon Transport for MLAPI](https://github.com/Unity-Technologies/mlapi-community-contributions/tree/master/Transports/com.mlapi.contrib.transport.photon-realtime) uses Photon relay server to facilitate communication between clients and server living on different networks.

:::unity Learn More
See the [Boss Room Photon Setup Guide](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/release/v0.1.0-experimental/Documentation/Photon-Realtime/Readme.md) for details.
See the [Boss Room Photon Setup Guide](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/master/Documentation/Photon-Realtime/Readme.md) for details.
:::

#### Port Forwarding

The [Portforward Site](https://portforward.com/) has guides on how to enable port forwarding on a huge number of routers. Boss Room uses UDP and needs a 9998 external port to be open.

import Iframe from 'react-iframe'

## Troubleshooting

import Iframe from 'react-iframe'
**Run builds on Mac OSX:**

If you attempt to run a build on OSX and receive a warning dialog mentioning an "unidentified developer", you may need to override your security settings for this application:

1. In the Finder on your Mac, locate the application you want to open.

:::note
Do use Launchpad, it does not allow you to access the shortcut menu.
:::

1. Control-click the app icon, then choose **Open** from the shortcut menu.
1. Click **Open**.
1. The app is saved as an exception to your security settings. You can open it in the future by double-clicking it just as you can any registered app.


See [Apple Support](https://support.apple.com/guide/mac-help/open-a-mac-app-from-an-unidentified-developer-mh40616/mac) for details.
19 changes: 8 additions & 11 deletions docs/learn/rpcnetvarexamples.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ See the [RPC vs NetworkVariable](rpcvnetvar.md) tutorial for more information.
Boss Room uses RPCs to send movement inputs.

```csharp reference
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/develop/Assets/BossRoom/Scripts/Client/Game/Character/ClientInputSender.cs

https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/master/Assets/BossRoom/Scripts/Client/Game/Character/ClientInputSender.cs
```

We want the full history of inputs sent, not just the latest value. There is no need for `NetworkVariable`s, you just want to blast your inputs to the server. Since Boss Room is not a twitch shooter, we send inputs as reliable `RPC`s without worrying about the additional latency an input loss would add.
Expand All @@ -23,7 +22,7 @@ We want the full history of inputs sent, not just the latest value. There is no
Sending from server to client `RecvPerformHitReactionClient`

```csharp reference
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/d09330434d864de384db0ce144aa30e5a20aeb3c/Assets/BossRoom/Scripts/Shared/Game/Entity/NetworkCharacterState.cs#L174
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/master/Assets/BossRoom/Scripts/Shared/Game/Entity/NetworkCharacterState.cs#L235-L239
```

For example, the Boss Room project "ouch" action `RPC` mentioned for `NetworkCharacterState` is interesting for optimization purposes. You would normally want to have only one `RPC` for an action and let the client decide who should play the associated animation. Due to "ouch" being a long running action over multiple frames, you do not know yet when sending the initial `RPC` which characters will be affected by that action. You want this to be dynamic as the boss is hitting targets. As a result, multiple `RPC`s will be sent for each hit character.
Expand All @@ -33,30 +32,28 @@ For example, the Boss Room project "ouch" action `RPC` mentioned for `NetworkCha
The archer's arrows uses a standalone `GameObject` that is replicated over time. Since this object's movements are slow moving, we made the choice to use state to replicate this ability's status, in case a client connected while the arrow was flying.

```csharp reference
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/develop/Assets/BossRoom/Scripts/Server/Game/Entity/ServerProjectileLogic.cs
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/master/Assets/BossRoom/Scripts/Server/Game/Entity/ServerProjectileLogic.cs
```

We could have used an `RPC` instead, for example the Mage's projectile attack. Since it is expected for that projectile to be quick, we are not affected by the few milliseconds where a newly connected client could miss the projectile and we save on bandwidth having to manage a replicated object. Instead a single RPC is sent to trigger the FX client side.


```csharp reference
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/develop/Assets/BossRoom/Scripts/Server/Game/Action/FXProjectileTargetedAction.cs
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/master/Assets/BossRoom/Scripts/Server/Game/Action/FXProjectileTargetedAction.cs
```

## Character life state

We could have used a "kill" `RPC` to set a character as dead and play the appropriate animations. Applying our "should that information be replicated when a player joins the game mid-game" rule of thumb, we used `NetworkVariable`s instead. We used the `OnValueChanged` callback on those values to play our state changes animation.

```csharp reference
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/5832b697a790595bc7d9afd3d5cc418c7318ccb8/Assets/BossRoom/Scripts/Shared/Game/Entity/NetworkCharacterState.cs#L63

https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/master/Assets/BossRoom/Scripts/Shared/Game/Entity/NetworkCharacterState.cs#L93
```

The animation change:

```csharp reference
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/5832b697a790595bc7d9afd3d5cc418c7318ccb8/Assets/BossRoom/Scripts/Client/Game/Character/ClientCharacterVisualization.cs#L49


https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/master/Assets/BossRoom/Scripts/Client/Game/Character/ClientCharacterVisualization.cs#L78
```

:::tip Lesson Learned
Expand All @@ -66,7 +63,7 @@ https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/58
![imp not appearing dead](/img/01_imp_not_appearing_dead.png)

```csharp reference
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/develop/Assets/BossRoom/Scripts/Client/Game/Character/ClientCharacterVisualization.cs !
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/master/Assets/BossRoom/Scripts/Client/Game/Character/ClientCharacterVisualization.cs
```

:::
Expand Down
13 changes: 5 additions & 8 deletions docs/learn/rpcvnetvar.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ If we sent an `RPC` to all clients, then all players connecting mid game after t
In that case, it is preferable to use `NetworkVariable`s like shown here.

```csharp reference
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/develop/Assets/BossRoom/Scripts/Shared/NetworkDoorState.cs
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/master/Assets/BossRoom/Scripts/Shared/NetworkDoorState.cs
```

It uses a `BoolNetworkVariable` to represent the "IsOpen" state. If I open the door and a player connects after this, the host will replicate all the world's information to that new player, including the door's state.
Expand All @@ -57,27 +57,26 @@ Actions in Boss Room are a great example for this. The area of effect action (`A
`AoeActionInput.cs` Shows the input being updated client side and not waiting for the server. It then calls an `RPC` when clicking on the area to affect.

```csharp reference
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/develop/Assets/BossRoom/Scripts/Client/Game/Action/AoeActionInput.cs

https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/master/Assets/BossRoom/Scripts/Client/Game/Action/AoeActionInput.cs
```

`AOEAction.cs` Server side logic detecting enemies inside the area and applying damage. It then broadcasts an `RPC` to tell all clients to play the VFX at the appropriate position. Character's state will automatically update with their respective `NetworkVariable`s update (health and alive status for example).


```csharp reference
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/develop/Assets/BossRoom/Scripts/Server/Game/Action/AOEAction.cs
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/master/Assets/BossRoom/Scripts/Server/Game/Action/AOEAction.cs
```

`AoeActionFX.cs` is triggered by an `RPC` coming from the server

```csharp reference
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/develop/Assets/BossRoom/Scripts/Client/Game/Action/AoeActionFX.cs
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/master/Assets/BossRoom/Scripts/Client/Game/Action/AoeActionFX.cs
```

:::tip
If you want to make sure two variables are received at the same time, `RPC`s are great for that.

If you change `NetworkVariable` "a" and "b", there's no guarantee they'll both be received client side at the same time. Sending them as two parameters in the same `RPC` allows to make sure they'll be received at the same time client side.
If you change `NetworkVariable` "a" and "b", there is no guarantee they will both be received client side at the same time. Sending them as two parameters in the same `RPC` allows to make sure they will be received at the same time client side.
:::

`NetworkVariable`s are great when you only care about the latest value.
Expand All @@ -89,5 +88,3 @@ If you change `NetworkVariable` "a" and "b", there's no guarantee they'll both b

`RPC`s are great for sending transient events. Use them when transmiting short lived events.



Loading