4

Player Structure

A player can take on any form – humans, aliens, vehicles, and so forth. Designing a structure that can deal with all of them is a challenge. The way we need to store data, the types of data we need to store, the various types of movement code and weapons and so on, can soon become complicated.

A basic player using the framework in this book would be made up of a GameObject containing Unity-specific physics or collision Components, then four additional script Components (as seen in Figure 4.1):

  1. The player controller

    A controller specific to game requirements – this may have functions to deal with game-specific operations like opening doors or holding the player in place before the game starts and so on

  2. A movement controller ...

Get C# Game Programming Cookbook for Unity 3D, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.