**Prototyping**
Vocabulary ==== 1. Game Engine * Software like Unity or UE that helps you build a game 2. Asset * Something created by an artist for the game (character, texture, audio file, ...) 3. Project / Game file * Everything the engine needs for the game 4. Scene / Level 1. Distinct part of game 2. Originally everything for one level, but main menu, player selection, etc. may be created as levels. 3. Large world games may use _level overlays_ with multiple levels loaded at once, each covering a region of the map. 5. Game Object / Entity / Actor * Things you can place in a scene: characters, objects, sound sources, triggers, etc. 6. Collision box 1. Simple shape around a game object, can trigger an action when these overlap 2. Used for physics, but also triggers, regions, power-ups, etc. 7. Editor 1. Part of engine that allows placing game objects in a scene. 2. Unity & UE have editors, but many AAA in-house engines don't! Building a Prototype ==== 1. Small!!! 2. Focus on critical exploration 1. New gameplay? 2. Artistic style? 3. Unique tech? 3. Leave everything else unfinished 4. Some rapid prototyping strategies 1. Physical (cards, dice, ...) 2. 2D prototype for 3D game 3. Mod existing Game organization ==== 1. Game or level state & code 1. Overall state of the game 2. Sometimes split into multiple (invisible) *manager* objects 2. Game object state & code 1. Each game object keeps track of its own position/velocity/health/ammo/etc. 2. Code to run when created, game start, spawn, etc. 3. Code to run each *tick* or *update* (game updates may be decoupled from frame updates) 4. Code to run on collision 3. Collision volumes 1. Originally for physics, but so much more useful 2. Bounding box, sphere, capsule, other shape 3. Trigger action when bounding shapes overlap 4. Zones, portals, ... 4. Events & Delegates https://gamedevbeginner.com/events-and-delegates-in-unity/ 1. Bits of code to run when something happens 2. Direct single call: Change functions when game state changes 3. Multicast: Inform other entities (often "On...") * OnCollision, OnPlayerDeath, Timed Game Example (Unity Platformer Microgame) ==== 1. In Unity Hub, create 2D 2. Set the scene 1. Add Floor 1. GameObject > 2D Object > Square, stretch to floor 2. Rename to "Floor" 2. Add Player 1. GameObject > 2D Object > Sphere 2. Rename to "Player" 3. Play (there, but fixed) 3. Player physics 1. Select Player: Add Component > Physics 2D > Rigidbody 2D 2. Play (drops through floor) 4. Add Colliders 1. Player: Add Circle Collider 2D 2. Floor: Add Box Collider 2D 3. Add script 1. Horizontal Motion * Player Add Component > New Script (PlayerController) ~~~~~ using UnityEngine; public class PlayerController : MonoBehaviour { private Rigidbody2D body; public float speed = 5; // Start is called before the first frame update void Start() { body = GetComponent(); } // Update is called once per frame void Update() { Vector2 v = body.velocity; v.x = speed * Input.GetAxis("Horizontal"); body.velocity = v; } } ~~~~~ 2. Jump ~~~~~ ... private ContactFilter2D filter = new ContactFilter2D(); public float jump = 5; ... void Start() { body = GetComponent(); filter.SetNormalAngle(90-15, 90+15); } ... void Update() { ... if (body.IsTouching(filter)) { if (Input.GetButtonDown("Jump")) v.y = jump; else v.x = speed * Input.GetAxis("Horizontal"); } ... } ~~~~~ 4. Add sprites 1. Open Photoshop, 128x128 RGB transparent 2. Draw first frame 3. Window > Timeline / Create Frame Animation 4. Add frame 1. Duplicate in timeline 2. Add layer 3. Reduce opacity of frame 1 layer 4. Modify for frame 2 5. Repeat for remaining frames 6. Convert to sprite sheet 1. Add frame with all layers 100% opacity 2. Change canvas size to NxN, anchor at top right 3. Select 2nd row, add 128 to Y position in Properties window 4. Select 3rd row, add 128*2 to Y ... 5. Select first column layers, add 128 to X, ... 6. Merge layers Command-shift-E 7. Export > Quick Export to PNG 7. Import into Unity 1. Drag into Asset window 2. Select new asset & look at Inspector on right 1. Change Sprite Mode to multiple 2. Click Sprite Editor button in inspector 3. Choose slice / Grid by Cell Size / 128x128 4. Drag into scene to create Animation & Animation Controller then delete * Can do each of these yourself, but easier to let it make them. 5. Set Player sprite component to use the new sprite asset 6. Add Animation Controller component & set to new one 8. Fix collision 1. Run & see that collision is whacked: offset and character tumbles 2. Freeze rotation with RigidBody 2D > Constraints > Freeze Rotation 3. Delete circle collider & create capsule or box 4. Edit collider and adjust to fit frames 5. Add background 1. Check game dimensions (mine is 2560x1440) 2. Create proportional image in Photoshop (e.g. 1024x576) 3. Import, drag into scene, resize 4. Delete sprite renderer from floor (so it's just an invisible collision box) Building a game ==== 1. Planning 1. Plan for characters 1. Assets needed 2. Behavior needed 2. Plan for level 1. Assets needed 2. Design 3. Any game state 4. Any environmental behavior 3. Use existing or build your own 1. Engine 2. Template or prior game 3. Tools 2. Start work in parallel 1. Rough out level (grey box / programmer art) 2. Character & environmental stills 3. Character & environmental animation 4. Constant communication and exchange