Your game will always have at least one Player, and it is important to be able to handle and manage details them such as their score and progress.

Player functionality is based upon GameItem and it’s related classes and so it inherits all features such as the ability to use in app purchase, unlocking, selection screens, saving of information and so forth. It is worth reviewing the Game Structure overview page first as this page will focus on additions and differences from those documented there.


You can setup players automatically through GameManager or manually through scripting. When using GameManager, you specify the number of players that you want (there must always be at least 1) and optionally a default number of lives they will have. Players will then be initialised based upon localisation strings and resource files as documented in the information about GameItems.

Player Setup Options

You can then access and set the current Player through GameManager.Instance.Player. There are also helper methods GetPlayer(int number) and SetPlayerByNumber(int number) for getting a specific player or setting the current player. Changing the Player will result in a message of type PlayerChangedMessage being sent out. If needed you can listed for this message and perform any updates to reflect that a new player is selected.

Object Model

The Player class represents an instance of a Player and inherits from GameItem exposing all of the same properties and methods. Player overrides IdentifierBase to ‘Player’ and IdentifierBasePrefs to ‘P’ to distinguish it from other GameItems. Player also contains a number of additional properties including:

Configuration files should be placed into the Resources\Player\ folder with the name Player_<ID> where ID corresponds to the Player’s ID.

In addition Player sends out custom messages when the score, highscore and coins change so that you can easily subscribe to changes of these values for the player. These messages are PlayerScoreChangedMessagePlayerHighScoreChangedMessage and PlayerCoinsChangedMessage respectively.

Player Selection

Due to a slightly different way of working, you will currently have to setup a custom player selection screen and call the GameManager.Instance.SetPlayerByNumber() method directly. Future updates might align with the way GameItem buttons are otherwise displayed.

The selected Player is available through the GameManager.Instance.Player property.

Player Display

The selected Player is available through the GameManager.Instance.Player property and so through this you can access things such as the currently selected players name, description, extension data etc.

The ShowPlayerInfo component can be added to a gameobject with a UI Text component to automatically update the Text display with customisable information about the currently selected Player.


Player Coins

Coins and Score

The ShowCoins, ShowScore and ShowHighScore components provide ways of displaying the current players coins, score and high score respectively. These components make use of the ShowValueAnimatedMessaging abstract component for automatically updating the display when updates occur. Updates can be aggregated in variety of different ways and any changes animated using a custom or predefined animation. (see the Animation\ValueChanges demo in the extras bundle)


The ShowLives component is a simple text bases way displaying the number of lives the player has. Like the components mentioned above this also makes use of the ShowValueAnimatedMessaging abstract component and so has the same features.

The EnableBasedUponNumberOfLives component allows you to shows one of two gameobjects based upon the number of lives the player has and a property indicating which life the component represents. You could create multiple gameobjects for each life and use this to selectively enable different child gameobjects representing whether the life has been lost or not. It will also automatically react to changes. Instead of manually creating multiple such gameobjects for each life you could instead use the CreateLivesIcons component to do this automatically based upon a prefab that represents what you want created for each available life and either the global or a specified life count.



The ShowHealthImage component can be attached to a gameobject containing a UI Image component whose Image Type is set to ‘Filled’. It will listed for changes to the players health and update the image fill percentage to match giving a nice health bar type feature.



Prefabs associated with Players can be setup and retrieved as discussed in the description on GameItem.

The Player specific InstantiatePlayerPrefab component is an implementation of InstantiatePrefab that will use prefabs from the currently selected Player.


Prefabs associated with Players can be setup and retrieved as discussed in the description on GameItem.

The Player specific SetImageToPlayerSprite and SetSpriteRendererToPlayerSprite components behave in a similar to their base components for setting sprites from the currently selected Player.

Making Changes

You can modify these values directly through scripting. In addition there are various components that you can use for displaying and working with the different properties.

The SetHealth and SetLives components let you set / reset the players health and number of lives. You should add these to a new level if you want these values reset.

DecreaseLivesWhenHealthIsZero will listen for health changes and decrease the players lives when their health reaches zero.

OnLifeLostEnableGameobject will enable a specified gameobject when the number of lives is lost, optionally disabling it again after a given period. This can be used for something like showing a text message when the player loses a life.

In addition you can use the health collider for changing these values automatically based upon Physics collisions.

Cheat Functions

Using the Cheat Functions window (Window Menu | Game Framework | Cheat Functions Window) you can manipulate the current Player to aid with testing of your game.


See also

If you have any thoughts or suggestions on improvements or additions to the Player features then please let us know!