Code Monkey home page Code Monkey logo

unity3d-gameplay-framework's Introduction

Unity3D Gameplay Framework

Introduction

All objects spawned in a Unity scene are Behaviours. For local games we work with MonoBehaviours and for networking games Unity provides us NetworkBehaviours. Aside from those there aren't many abstractions where Unity supports us. I came to the conclusion that great gameplay support should be a feature that ships with the engine, finding myself abandoning projects because it doesn't.

I've worked with Unreal's Gameplay Framework which I really like and therefore want to improve Unity's gameplay layer by adding some of the things I have learned from UE4 (Unreal Engine 4). However, the existing Behaviour code base cannot be removed as it lies at the heart of the Unity Engine.

Glossar

Terminology Description
Player A player is a real human. Note that AIs (Bots) are not players.
Participant Players and AIs can become participants when they request to join a game. Participants are taking part in the game and can interact with the world. They can have a huge imapact on the outcome of the game. A player spectator that is not able to interact with the world is not a participant for example.
Authority The authority can either be a local client, a remote client (Host) or a server. A networking game has many actions that require to be authorized before they can happen. Win/Loose conditions are usually evaluated by the authority to prevent cheating for example.

The Gameplay Framework Classes

The Gameplay Framework consist of a few classes that help to structure gameplay logic.

General

Game Class

The Game class is a Singleton that provides general interaction with the game. Controllers join the Game to become participants for example.

GameMode Class

The GameMode only exists on the authority. The authority's Game instance contains the only GameMode across all participants. The GameMode constantly evaluates the GameState for new events that require authorization. It checks win/loose conditions as a common example.

GameState Class

All Games across all participants contain a single GameState that is synchronized over the network. As the name suggests, this class contains the state of the game. However, not all information about the game must be stored in this class. Only data that must be autorized is required to be available in the GameState.

ParticipentState Class

The GameState contains a collection of ParticipantStates. They contain the information of a participant that requires to be authorized. All participants have a ParticipantState.

Controllers

A Controller represents the will of a player or an AI. It can possess a single pawn at the time and/or become a participant by requesting a join.

PlayerController Class

A PlayerController is a controller that represents the will of a player.

AIController Class

An AIController is a controller that represent artificial intelligence.

Pawns

An IPawn is an entity that can become possessed by a single Controller at a time. When possessed, a pawn follows the instructions of its Controller.

MonoPawn Class

MonoPawns are IPawns that are used for local play. They inherit from MonoBehaviour.

NetworkPawn Class

NetworkPawns are IPawns that are used for network play. They inherit from NetworkBehaviour and are currently not implemented due to a focus on local play for a first version of the Gameplay Framework.

Player Managers

PlayerManagers are associated by PlayerControllers and handle the interaction between the game and the players. AIControllers do not require PlayerManagers because an AI doesn't require visual feedback.

PlayerInputManager Class

A PlayerInputManager reads the input from the input devices of its player and prepares the information for its PlayerController. It does not interpret the input but is allowed to make device specific corrections such as applying a deadzone to an analogue stick.

PlayerCameraManager Class

PlayerCameraManagers are the cameramen in a game. Their main job is to position and rotate the camera correctly as well as performing any post-processing on the rendered image.

PlayerHUDManager Class

A PlayerHUDManager is responsible to display a player's HUD (Heads Up Display).

unity3d-gameplay-framework's People

Contributors

maximetinu avatar noelwidmer avatar

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.