Giter VIP home page Giter VIP logo

mirror-lobby's Introduction

Mirror Lobby

Open-source Boilerplate project

This repo contains an open-source Networked multiplayer Unity game project developed by Alexandria Pagram.

  • The game loads with a main menu as its first scene.
  • Players are given the option to create their own lobby or join an existing lobby [P2P connection].
  • Rounds are timer-based.
  • A basic score system exists.
  • At the end of each round, the player with the highest score is displayed onscreen.
  • Players can choose to start another round in the same lobby, or to exit the lobby and return to the main menu.
  • There is some basic error-handling, such as network errors and what should happen when the Host leaves the game.

It uses the popular Mirror library for its multiplayer, a fork/extension of Unity's deprecated HLAPI. Currently, the game uses a peer-to-peer (P2P) connection - similar to Terraria and Don't Starve Together. A server-based system would be a nice-to-have option for players sometime in the future (if anyone has any ideas, message me!)

To understand how to sync movement and variables between clients, and to understand when and how to run methods serverside, please consult the Mirror or Unity HLAPI docs and join the Mirror discord community.

USE UNITY VERSION 2019.4.1f1 https://unity3d.com/unity/qa/lts-releases

Using this project:

Please flag any bugs as issues on the github repository, or message me on discord and I'll add it to a Trello board. Feel free to submit PR's to fix any bugs or to extend the functionality of this project.

If you want to make your own game, I'd be delighted if you'd fork this project. Any PR's for this repository should be made with the intent to maintain or extend this 'boilerplate' lobby system for other users to easily fork.

Background on the important files:

The player prefab has the Player.cs class at its root, as well as a network identity and flexnetworktransforms to link up any movement over the network.

There is a ScoreManager and a RoundSystem class that I've stripped back for you to customise.

The LobbyNetworkManager.cs is where my custom lobby networking code sits. It overrides Mirror's default NetworkManager.cs class.

Some of the basics of this lobby system were created by using parts of Dapper Dino's lobby project and the Mirror example 'Room' project as references.

# Dapper Dino - Mirror Lobby tutorials
https://www.youtube.com/watch?v=5LhA4Tk_uvI&list=PLS6sInD7ThM1aUDj8lZrF4b4lpvejB2uB&ab_channel=DapperDino

# Mirror Networking Library
https://mirror-networking.com/

Instructions - scenes and players:

Menu scene - the default scene & default Offline scene.

Here is where a player enters their name, and decides whether to host or join a game.

Lobby scene - the default online scene.

Here is where a player is taken once they become a part of a lobby. There is minimal GUI elements currently, as the lobby overlay is actually attached to the lobby player prefabs.

Game scene - where the game takes place.

'RoomPlayers' (type of LobbyPlayer) are persistent between rounds.

'GamePlayers' (type of Player) are created for each player once they join the Game scene. They are destroyed between rounds.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.