Taylor and Francis Group is part of the Academic Publishing Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 3099067.

Informa

Students

Click on the tabs below to view the content for each chapter.

Introduction for Students

Throughout Design Games for Architecture, you will be learning a wide variety of new skills as you complete each project. Your tool will be Unity, a powerful video game development environment. You will learn how to use Unity to create interactivity, visual effects, and components that behave in intelligent ways and much more.

In each chapter you will build a design game: a creative tool that borrows key concepts from the world of video gaming. Design games can create forms, structures and other products through playful interaction. A design task will be presented at the beginning of each chapter and you will build a design game that carries out that task in a novel way. Learning how to create design games teaches new ways to think about design processes. In the end, you will have gained the skills to enable you to invent tools to explore these processes in new and engaging ways.

To get started, download unity and the DesignGamesResources code. As you work through each chapter of the book, refer back to this website for videos, troubleshooting tips and other resources.

Tools of the Trade

Chapter Summary

This chapter will introduce you to Unity, industry-leading software for the creation of video games. To take advantage of Unity’s wide array of capabilities requires some basic familiarity with its user interface. “Tools of the Trade” walks readers through the elements of this interface that control the view into the virtual scene, creation of new objects and the placement of those objects into the scene. The purpose of panels that help manage assets and give feedback on the properties of objects is explained. Finally, a short example project introduces the concept of scripting and the role it plays in defining the behavior of design games.

Videos

Interface Overview

The Scene View

What Went Wrong?

When something unexpected happens, as it often does in software development, how can you get back on the right track? Though it’s difficult to account for every situation, this section on each chapter page will describe some of the most common mishaps and offer methods to fix what went wrong.

Problem: After creating the script and adding the code to the Update function, nothing happens when I click play.

Solution: Ensure that you have attached the script to the cube object. You can check this by selecting the cube in the Hierarchy and verifying that the “New Behavior Script” appears there. To attach the script, drag it from the Project view onto “Cube” in the Hierarchy. You can also do this by dragging the script into the Inspector when the cube is selected in the Hierarchy.

Problem: After adding some code to my script I try to play the design game, but nothing happens.

Solution: Take a look at the very bottom of the Unity window. There is a box that runs the length of the window that displays messages when something goes wrong. If there is a message there in red text, it means there is an error in your code. The numbers in parentheses indicate the line number and the column number where the error occurred. Double clicking the error will bring up your script with that line highlighted. Many times the error message will have a suggestion about what needs to change. Messages like “‘;’ expected. Insert a semicolon at the end.” are quite common and straightforward to fix. Some error messages are more cryptic and may require you to look back at the code in the book to see if you mistyped anything. When in doubt, search Unity Answers with the text from the error to find solutions.

Further Exploration

After you complete Chapter 1, try exploring a bit. Change a number, like the 0.5 in the Update function and see what the result is. Continue changing values, testing in between each change. Free form exploration like this can teach you a lot about how code works.

Additional Resources

  • Learn Unity

    Under the Tutorials section you will find many great videos and example projects to help you learn more about Unity. Watch these as you work through the projects in the book. Under Documentation you will find the User Manual, Component Reference and Scripting Reference. Familiarize yourself with these resources, as they are essential to solving many problems.

  • Unity Answers

    Unity Answers is a great resource for finding solutions to any problem you might have. Developers ask and answer questions here and the best answers get voted up, making it clear what the best solution is.

Building Blocks

Chapter Summary

In this chapter, you will build a simple design game that is played by arranging falling blocks on a game board. Starting with a simple cube object, you will write code that manages the timing of the game, keyboard controls and randomization, among other aspects. Setting the scale, rotation and position of objects is explored thoroughly. You will learn how to detect when a block has collided with other objects in the scene and how to determine when a game is over. At the completion of the exercise you will be able to play the game over to explore new forms that can be created with the falling blocks.

Videos

Scripts as Behavior Components

Variables and Functions

IF Statements

Loops

What Went Wrong?

Problem: When I open the BuildingBlocksStarter project, I don’t see the game board and other objects described in the chapter.

Solution: At the very top of the Unity window, you will see the name of the current scene being edited. If this reads “Untitled,” you will need to double click the MainScene in the Project browser to make it active. Often times Unity will create a new scene like this. By checking the scene name at the top of the window, you can verify that you are editing the correct scene.

Problem: I get an “UnassignedReferenceException” error when I first try to play the design game.

Solution: This error occurs when one of the variables in the GameController script hasn’t been assigned a value. The error message will tell you which of the variables this is. Highlight the Main Camera in the Hierarchy and look in the Inspector for the line corresponding to the variable name. If, for instance, the unassigned variable is Block_prefab, make sure that you drag the Block prefab onto this line in the Inspector.

Problem: After I click play I can’t see the game board, or see it at an unusual angle.

Solution: Ensure that you assigned the camera position variables (Cam_pos_1, etc.) their correct values as described in Section 2.5. If these vector values are set to other values, you may not see the game board at all or see it from a strange angle.

Problem: At the end of Section 2.7, Falling, I click play but the block doesn’t fall toward the game board or appears resting on the game board.

Solution: There are two likely causes of this malfunction. The first is in the line current_block.transform.position.y -= falling_step in the Update function. Ensure that you have typed -= and not only the equals sign. This subtracts the value of falling_step from the cube’s vertical position each frame, causing it to fall. The other potential cause is that falling_step is set to zero. If this is the case, the code is subtracting zero from the block’s height with no resulting fall. With the Main Camera highlighted in the Hierarchy, make sure that falling_step is set to 1 in the Inspector.

Other Problems: When you click play and something goes wrong, remember to always check the bottom of the Unity window for an error. The error message should point you to the specific line in the script where the error occurred. Usually this is as simple as a missing semicolon or a misplaced curly bracket. Go back to the code in the chapter to verify you’ve typed everything correctly. If you’re still stuck, open up the BuildingBlocksFinished project and take a look at the complete code.

Further Exploration

Read through the Further Exploration section at the end of the chapter. Try to find a solution to each of these challenges. Looking in the CreateBlock function will get you started on the first one.

Additional Resources

  • Building Scenes

    This section of the Unity manual gives a comprehensive overview on what GameObjects, Components and Prefabs are and how they function.

  • GUI Scripting Guide

    This section of the Unity Scripting Reference explains how to build graphical user interfaces with text, buttons and other controls that a player can interact with.

Slingshot

Chapter Summary

In this chapter you will create a design game named Slingshot. Playing involves launching pieces of lumber at each other which stick together to form unique and unusual assemblages. By building Slingshot you will learn about simulating physics in Unity. This includes vectors to determine direction, forces that cause objects to move and collisions between objects. To offer feedback to the player, you will create some graphical interface elements on the screen that indicate which actions are being performed, a score and other data. You will also explore ways to create a variety of three-dimensional objects from a template object through randomization.

Videos

Colliders

Rigidbodies

AddForce

AddTorque

What Went Wrong?

Problem: When launching lumber, some pieces fly off into the scene and don’t enter the PlayBox.

Solution: Each piece of lumber is aimed using the position of the mouse cursor and a variable named aimingRatio that is described in Section 3.5. The aimingRatio variable is set by default to 0.01, but depending on the size and shape of your screen this may not be ideal. Try decreasing or increasing the value of aimingRatio until the lumber consistently lands in the PlayBox.

Problem: After launching lumber, it seems to bounce and not enter the PlayBox.

Solution: The PlayBox is made up of six faces. The face on the front, closest to the camera, has its visibility turned off. Even though it’s invisible, physics objects like the lumber will still collide with it. In Section 3.7 there is code that turns off the collision detection of the lumber (listing 3.7) and turns it back on (listing 3.8) once it is inside the PlayBox. Make sure this code is correct.

Problem: When I click play, the game over message is displayed right away.

Solution: Highlight the MainCamera in the Hierarchy and ensure that the GameTimer variable is set to 120. If it’s 0, the game will be over right at the start. You can increase or decrease this value to change the length of time each game takes.

Further Exploration

Read through the Further Exploration section at the end of the chapter. Try to find a solution to each of these challenges. Look at the CreateLumber function to get started on the first challenge.

Additional Resources

  • Understanding Vector ArithmeticA useful overview for those needing a refresher on vector math.
  • PhysicsThe Physics section of the Unity manual has detailed information on colliders, rigidbodies and other physics components.
  • Game Interface ElementsThe GUI Scripting Guide section of the Unity manual explains in detail how to add buttons, text and other graphical controls.

Kirigami

Chapter Summary

In this chapter you will build a design game based on Kirigami, the art of cutting and folding paper. Physical joints are introduced to link together a series of triangular panels into a seamless piece of simulated paper. You will write code that allows a player to see where this paper can be cut or folded. The joints will be controlled via code as well, enabling the paper to fold at a variety of angles or split to establish a cut. User interface elements will give the player a choice of constraints for each session: limits on time or the number of actions that can be executed. Additional graphic elements will show the player their progress.

Video

Hinges

What Went Wrong?

Problem: When I first attempt to test out folding in Section 4.5, the triangle tiles spin or make other strange movements instead of creasing along their edges.

Solution: The parameters of the hinge joint may not be set correctly. Select the triangle with the hinge joint and verify that the parameters in the Inspector have the right values as specified in Figure 4.4. If the Axis isn’t set to (1, 0, 1) or the Anchor isn’t set to (0, 0, 0), the joint won’t work as expected.

Problem: After Section 4.8 Assembling the Paper, I click play but the sheet of paper is missing half of the triangle tiles.

Solution: Your PaperTile prefab may not be complete. Refer back to Figure 4.10 which shows how the triangle tiles and joint indicators are parented to the PaperTile. If any of these objects were not parented to the PaperTile when the prefab was created they will be missing when the CreateSheet function makes copies. Try assembling the square tile again by revisiting Sections 4.5 and 4.6.

Further Exploration

Read through the Further Exploration section at the end of the chapter. Try to find a solution to each of these challenges. To get started on the first challenge, try modifying the scale of the paper tile prefab.

Additional Resources

  • Hinge JointFind more information about hinge joints in the Unity Component Reference.

Component Lab

Chapter Summary

In this chapter you will build a complex simulation based on the logic of molecular bonding. Component Lab is a design game that presents players with a virtual “beaker” into which they can place an array of intelligent components. These components seek each other out and, if compatible, bond together to form larger, aggregate structures. Physical components like the joints explored in the previous chapter, plus some code that you will write, enable this behavior. Graphical interface elements will allow the player to add components to the simulation and pause the action to get a better look at the assemblage of components. You will also add code that allows the player to intervene in the bonding process by pulling components around in the beaker.

What Went Wrong?

Problem: I get a lot of errors when I save the scripts or try to play the design game.

Solution: This project is the most code intensive in the book. Errors are to be expected and most of them are easy to fix. At the very bottom of the Unity window, errors will appear in red. Take note of the message displayed; it usually will give you some hints about what needs to be fixed. Double clicking on the error message will send you directly to the line of code where the error occurred. Most commonly you should be looking for misspellings and missing semicolons, parentheses or curly brackets. When in doubt, do a search using the error message; the solution is almost always waiting for you.

Problem: The components start to bond together into groups, but at some point the simulation doesn’t proceed as two components attempting to bond (with the yellow line between them) never finish bonding.

Solution: Some pairs of components won’t be able to bond, since their progress is blocked by others. Section 5.13 goes over the code that tells components attempting to bond that they should give up after trying for some time. After verifying that this code is correct, highlight the RoundedBar prefab in the Project view and make sure the Bonding Time Limit variable is set to 2. If this variable is set too high, the components may try to bond for a long time even though it’s impossible.

Problem: The components seem to bond together very fast or very slow.

Solution: The ComponentController script has two variables that control how quickly bonding happens. By highlighting one of the component prefabs in the Project view, you should be able to see the Bonding Force and Bonding Velocity variables in the Inspector. By default these are set to 20 and 5 respectively. Changing these values for each of the component prefabs (RoundedBar, etc.), you can tune the speed at which bonding takes place. Decrease the values and the simulation will happen in slow motion. Raise them and things will happen very quickly. Increasing Bonding Force may introduce some erratic behavior. Bonding Velocity allows more precise control over the speed at which bonding occurs.

Further Exploration

Read through the Further Exploration section at the end of the chapter. Try to find a solution to each of these challenges. Look at Additional Resources below for information that will help you find solutions.

Additional Resources

  • Importing AssetsThis page in the Unity manual gives advice on importing 3D models, images and sound files.
  • 3D FormatsDetails on which 3D model formats are supported in Unity.
  • Fixed JointDetails on fixed joints in the Unity Component reference.

Showroom

Chapter Summary

In this chapter you will create a virtual tour of an architectural design. Several techniques are explored that move architectural visualization away from simple fly-through animations toward something more closely resembling a video game. You will use Unity’s animation system to create moving elements that guide the player through the scene. Lighting techniques that add realism to the virtual environment are explained. With a bit of code, you will also add interface elements that give the player more information about the design they are exploring.

Further Exploration

Read through the Further Exploration section at the end of the chapter. Try to find a solution to each of these challenges. To start on the first, take a look at the Light page in the Unity Component Reference listed below in Additional Resources.

Additional Resources

  • Positioning GameObjects:Explains the various ways to position objects using the Scene view. Pay particular attention to the Vertex and Surface Snapping sections.
  • Animation View GuideDiscusses the interface of the Animation view and how it functions.
  • LightDetails the parameters of lighting components.
  • Lightmapping QuickstartAn introduction to lightmapping, a method of “baking in” lighting effects in a scene.