Tai lieu lap trinh game android bang unity 3d chuyen nghiep,tai lieu hay,ebook lap trinh game,hoc lap trinh game,game unity 3d,lam game chuyen nghiep voi unity 3d,cong nghe lam game 3d,lap trinh unity3d,ebook game,sach hoc lap trinh game
Chapter The Art of Programming Mechanics Everyone can be taught to sculpt: Michelangelo would have had to be taught how not to So it is with the great programmers Alan Perlis 1.1 Introduction In 1979, art teacher Betty Edwards published the acclaimed Drawing on the Right Side of the Brain The essence of the text taught readers to draw what they saw rather than what they thought they saw The human brain is so adept at tasks such as pattern recognition that we internally symbolize practically everything we see and regurgitate these patterns when asked to draw them on paper Children this very well The simplicity in children's drawing stems from their internal representation for an object Ask them to draw a house and a dog and you'll get something you and they can recognize as a house and dog or, more accurately, the icon for a house and Holistic Game Development with Unity © 2012 Elsevier, Inc All rights reserved Holistic Game Development with Unity Fig 1.1 Dogs in the yard of a castle by Tabytha de Byl aged dog, but something far from what an actual house and dog look like This is evident in the child's drawing in Figure 1.1 The title of the book, Drawing on the Right Side of the Brain, also suggests that the ability to draw should be summoned from the side of the brain traditionally associated with creativity and that most bad drawings could be blamed on the left Different intellectual capability is commonly attributed to either the left or the right hemispheres The left side being responsible for the processing of language, mathematics, numbers, logic, and other such computational activities, whereas the right deals with shapes, patterns, spatial acuity, images, dreaming, and creative pursuits From these beliefs, those who are adept at computer programming are classified as left-brained and artists as rightbrained The segregation of these abilities to either side of the brain is called lateralization While lateralization has been generally accepted and even used to classify and separate students into learning style groups, it is a common misconception that intellectual functioning can be separated so clearly In fact, the clearly defined left and right brain functions are a neuromyth stemming from the overgeneralization and literal isolation of the brain hemispheres While some functions tend to reside more in one side of The Art of Programming Mechanics the brain than the other, many tasks, to some degree, require both sides For example, many numerical computation and language activities require both hemispheres Furthermore, the side of the brain being utilized for specific tasks can vary among people Studies have revealed that 97% of right-handed people use their left hemisphere for language and speech processing and 70% of left-handed people use their right hemisphere In short, simply classifying programmers as left brainers and artists as right brainers is a misnomer This also leads to the disturbing misconception that programmers are poor at art skills and that artists would have difficulty understanding programming Programming is so often generalized as a logical process and art as a creative process that some find it inconceivable that programmers could be effective as artists and vice versa When Betty Edwards suggests that people should use their right brain for drawing it is in concept, not physiology The location of the neurons the reader is being asked to use to find their creative self is not relevant What is important is that Dr Edwards is asking us to see drawing in a different light—in a way we may not have considered before Instead of drawing our internalized symbol of an object that has been stored away in the brain, she asks us to draw what we see To forget what we think it looks like In the end this symbolizes a switch in thinking away from logic and patterns to images and visual processing There is no doubt that some people are naturally better at programming and others at art However, by taking Edwards' anyone can draw attitude, we can also say anyone can program It just requires a little practice and a change of attitude 1.2 Programming on the Right Side of the Brain While it is true that pure logic is at the very heart of all computer programs, it still requires an enormous amount of creativity to order the logic into a program The process is improved greatly when programmers can visualize the results of their code before it even runs You may liken this to a scene from The Matrix where the characters look at screens of vertically flowing green numbers and text but can visualize the structure and goings on in a photorealistic, three-dimensional virtual reality To become a good computer programmer you need to know the language of the code and be able to visualize how it is affecting the computer's memory and the results of running the program Learning a computer language is one key to being able to program However, understanding how the language interacts with the computer to produce its output is even more important Good programmers will agree that it is easy Holistic Game Development with Unity to switch between programming languages once you have mastered one The fundamental concepts in each are the same In some languages, such as C, C++, C#, Javascript, Java, and PhP, even the text and layout look the same The basic code from each aforementioned language to print Hello World on the computer screen is shown in listings 1.1 through 1.6 Listing 1.1 C #include < stdio.h> main() { printf("Hello World"); } Listing 1.2 C++ #include < iostream > using namespace std; void main() { cout < < "Hello World" < < endl; } Listing 1.3 C# public class HelloWorld { public static void Main() { System.Console.WriteLine("Hello World"); } } Listing 1.4 JavaScript (in Bold) Embedded in HTML Hello World document.write(‘Hello World’); The Art of Programming Mechanics Listing 1.5 Java class helloworld { public static void main(String args[]) { System.out.println("Hello World"); } } Listing 1.6 PHP Umberto Eco, the creator of Opera Aperta, described the concept of art as mechanical relationships between features that can be reorganized to make a series of distinct works This too is true of programming The same lines of programming code can be reorganized to create many different programs Nowhere is this shared art/programming characteristic more obvious than in fractals Fractals are shapes made up of smaller self-similar copies of themselves The famous Mandelbrot set or Snowman is shown in Figure 1.2 The whole shape is made up of smaller versions of itself As you look closer you will be able to spot tens or even hundreds of smaller snowman shapes within the larger image A fractal is constructed from a mathematical algorithm repeated over and over where the output is interpreted as a point and color on the computer screen The Mandelbrot set comes from complex equations, but not all fractal algorithms require high-level mathematical knowledge to understand The Barnsley fern leaf is the epitome of both the creative side of programming and algorithmic nature of art Put simply, the algorithm takes a shape, any shape, and transforms it four times, as shown in Figure 1.3 It then takes the resulting shape and puts it through the same set of transformations This can be repeated infinitum; however, around 10 iterations of this process give a good impression of the resulting image (see Figure 1.4) Creating images with these types of algorithmic approaches is called procedural or dynamic generation It is a common method for creating assets such as terrain, trees, and special effects in games Although procedural generation can create game landscapes and other assets before a player starts playing, procedural generation comes into its own while the game is being played Holistic Game Development with Unity Fig 1.2 The Mandelbrot set and periodicities of orbits Fig 1.3 Transformations of Barnsley's fern leaf Original Shape Transform shrink & slightly tilt clockwise about degrees Transform quarter the size, & tilt approx 45 degrees clockwise Transform quarter the size, & tilt approx 45 degrees anticlockwise Transform halve the size, & squash into upright line Resulting Shape The Art of Programming Mechanics (b) (a) (c) Fig 1.4 Three iterations of Barnsley's fern leaf transformations after (a) iterations, (b) iterations, and (c) 10 iterations Programming code can access the assets in a game during run time It can manipulate an asset based on player input For example, placing a large hole in a wall after the player has blown it up is achieved with programming code This can only be calculated at the time the player interacts with the game, as beforehand a programmer would have no idea where the player would be standing or in what direction he would shoot The game Fracture by Day Studios features dynamic ground terrains that lift up beneath objects when shot with a special weapon For Research Procedural Generation in Unity The Unity Web site has a project with numerous procedural generation demonstrations At this point in your game development learning journey, you may not be able to understand the underlying code, but the examples will show you what is possible and the types of things you will be able to achieve by the end of this book The Unity project can be downloaded from http://unity3D.com/support/resources/files/ Procedural.zip A purpose-built programming language for creating art is Processing The syntax of the code is not unlike JavaScript and contains all the fundamental programming concepts you will learn about in Section 1.4 The image in Figure 1.5 was created with Processing by randomly plotting circles and drawing a series of curves from a central location to each circle Art created by Casey Reas, shown in Figure 1.6, created with Processing has been displayed at Gallery [DAM] Berlin Holistic Game Development with Unity Fig 1.5 An image created with Processing Fig 1.6 Artwork created by Casey Reas using Processing as exhibited at Gallery [DAM] Berlin The Art of Programming Mechanics For Research Getting Started with Processing If you're interested in learning more about Processing and drawing images with programming code, you can download the open source language and find tutorials at http://processing.org 1.3 Creating Art from the Left Side of the Brain Most people know what they like and don't like when they see art However, if you ask them why they like it they may not be able to put their thoughts into words No doubt there are some people who are naturally gifted with the ability to draw and sculpt and some who are not For the artistically challenged, however, hope is not lost This is certainly Betty Edwards' stance A logical approach to the elements and principles of design reveals rules one can apply to create more appealing artwork They are the mechanical relationships, alluded to by Umberto Eco, that can be used as building blocks to create works of art These fundamentals are common threads found to run through all good artwork They will not assist you in being creative and coming up with original art, but they will help in presentation and visual attractiveness The elements of design are the primary items that make up drawings, models, paintings, and design They are point, line, shape, direction, size, texture, color, and hue All visual artworks include one or more of these elements In the graphics of computer games, each of these elements is as important to the visual aspect of game assets as they are in drawings, painting, and sculptures However, as each is being stored in computer memory and processed by mathematical algorithms, their treatment by the game artist differs 1.3.1 Point All visual elements begin with a point In drawing, it is the first mark put on paper Because of the physical makeup of computer screens, it is also the fundamental building block of all digital images Each point on an electronic screen is called a pixel The number of pixels visible on a display is referred to as the resolution For example, a resolution of 1024 × 768 is 1024 pixels wide and 768 pixels high Each pixel is referenced by its x and y Cartesian coordinates Because pixels are discrete locations on a screen, these coordinates are always in whole numbers The default coordinate system for a screen has the (0,0) Holistic Game Development with Unity pixel in the upper left-hand corner A screen with 1024 × 768 resolution would have the (1023,767) pixel in the bottom right-hand corner The highest value pixel has x and y values that are one minus the width and height, respectively, because the smallest pixel location is referenced as (0,0) It is also possible to change the default layout depending on the application being used such that the y values of the pixels are flipped with (0,0) being in the lower left-hand corner or even moved into the center of the screen 1.3.2 Line On paper, a line is created by the stroke of a pen or brush It can also define the boundary where two shapes meet A line on a digital display is created by coloring pixels on the screen between two pixel coordinates Given the points at the ends of a line, an algorithm calculates the pixel values that must be colored in to create a straight line This isn't as straightforward as it sounds because the pixels can only have whole number coordinate values The Bresenham line algorithm was developed by Jack E Bresenham in 1962 to effectively calculate the best pixels to color in to give the appearance of a line Therefore, the line that appears on a digital display can only ever be an approximation to the real line as shown in Figure 1.7 Fig 1.7 A real line and a Bresenham line Bresenham Line Vector Line 10 Focal Press is an imprint of Elsevier 225 Wyman Street, Waltham, MA 02451, USA The Boulevard, Langford Lane, Kidlington, Oxford, OX5 1GB, UK © 2012 Elsevier, Inc All rights reserved No part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or any information storage and retrieval system, without permission in writing from the publisher Details on how to seek permission, further information about the Publisher's permissions policies and our arrangements with organizations such as the Copyright Clearance Center and the Copyright Licensing Agency, can be found at our website: www.elsevier.com/permissions This book and the individual contributions contained in it are protected under copyright by the Publisher (other than as may be noted herein) Notices Knowledge and best practice in this field are constantly changing As new research and experience broaden our understanding, changes in research methods, professional practices, or medical treatment may become necessary Practitioners and researchers must always rely on their own experience and knowledge in evaluating and using any information, methods, compounds, or experiments described herein In using such information or methods they should be mindful of their own safety and the safety of others, including parties for whom they have a professional responsibility To the fullest extent of the law, neither the Publisher nor the authors, contributors, or editors, assume any liability for any injury and/or damage to persons or property as a matter of product liability, negligence or otherwise, or from any use or operation of any methods, products, instructions, or ideas contained in the material herein Library of Congress Cataloging-in-Publication Data Application submitted British Library Cataloguing-in-Publication Data A catalogue record for this book is available from the British Library ISBN: 978-0-240-81933-4 For information on all Focal Press publications visit our website at www.elsevierdirect.com 11 12 13 14 5 4 3 2 1 Printed in the United States of America Index Note: Page numbers followed by b indicates boxes, f indicates figures and t indicates tables A A* algorithm, 269 currentNode variable, 277 debug lines showing paths, 277, 278f GameObject, 270 pathfinding, movement commands to character, 275, 275b Patrol button, 274 patrol JavaScript code, 270, 272b patrolling scene, 270 robot guard, traverse waypoints, 273, 273b robot model, 270, 271f robot-robot1, 270 self-motivated character, 277 waypoint layout, 270, 271f aardbeistudios, 458 AI see Artificial intelligence Animation mechanics animated sprites AnimatedSprite.js file, 157, 157b, 158, 159, 159b, 160b animation play speed, 160 Anime Studio Pro, 162, 162f png files, Adobe Flash, 162 scrollBackground.js file, 160, 161b specific gesture animation, 156 walk cycle, 157, 157f walkcycle texture effect, 158, 159f walking character illusion, 157, 157f walk.js file, 161, 161b animation management blending (see Blending) character action sequences, 181 single 2D sprite actions (see Single 2D sprite actions) single-filed 3D animations (see Single-filed 3D animations) baked 3D animations animationController.js file, 166, 166b animationControls.js file, 167, 168, 168b, 169b, 170 Autodesk's 3DS Max and Maya, tools, 164 baked, definition, 163 bind pose, 165 blend animations, 167–168 camera positioning, 168, 169f capsule collider, 166, 167f fbx animated model, 165 initial frames, same character, 163–164, 164f model and animation, 165, 165f Splinter Cell/Grand Theft Auto, 163 walking styles, 163 biomechanics applied mechanics, kinematics, 172 degree of freedom, 173–174 forward kinematics, 172, 172f H-Anim specification, 171, 171f Humanoid Animation Working Group, 171 inverse kinematics (see Inverse kinematics) mechanical movement, biological systems, 170 frame, 150 persistence of vision, 149–150 Phi, 149–150 predrawn graphics, 150 secondary animation Assassin's Creed, 198 avatars, 198 BackfaceOn.js file, 200, 200b cape model, 199, 199f cape transforms, 199f, 200 character's collider variable, 199f, 200 final character with cloth cape, 201, 202f law of physics, 198 Spacewar, 150, 151f sprites draw calls, 151, 151b rocket ship and planet, 150–151 texture atlas definition, 152 Gimp, 152–153, 153f setSprite.js file, 154, 155b Shader code, 154, 154b startPixel and endPixel values, 155, 156f Anticipation, 122 blob.js file, 130, 130b racing games, implementation, 130 Application programming interfaces (APIs), 447 AR see Augmented Reality Arrays array index, 55 colored cubes, stack, 55, 56f stackedColors.js file, 55, 55b storage boxes, game objects, 54, 55b Artificial intelligence (AI), 257–258 Augmented Reality (AR) cube positioning, marker, 445, 446f fiduciary marker, 444 high-quality animated virtual objects, 444 Image Target prefab, 445 marker setting, 445, 445f point of view (POV), 444 QCAR-1.0.unitypackage, 444 QualComm Unity Extension, 444 Unity running on Android, 445, 446f virtual game characters, 444 Average method, 400 Avoidance and collecting box collider, 242, 243f built-in instinct, avoidance, 242 chassis collider, 245 cube creation, platform, 243, 244f definition, 242 finish.js file, 245, 245b, 246, 246b, 247, 248, 248b font size, 245, 246f GUIStyle properties, 247, 247f myStyle, 247 releaseDuck.js file, 244, 244b RubberDucky model, 243 Unity GUI system, 247b work saving, 249 479 Index B Behavior management techniques confusion, 254 extinction, 254 negative punishment, 254 negative reinforcement, 253 positive punishment, 254 positive reinforcement, 253 BFS see Breadth-first search Blending animation management animationManagement script, 195, 195b, 196–197, 196b, 197b AnimationManager.js file, 194, 194b, 195 combined animations, 194 Boolean algebra and Boolean functions, definition, 29 Breadth-first search (BFS), 267–268, 267b, 268f Bresenham line algorithm, 10 C Camera audio listener, 85 background property, 84 frustum, 80 game view camera, 84 orbit.js file, 86, 86b perspective and orthographic camera, 3D scene, 80, 82f perspective projection, 80, 81f plane addition, 86, 87f pro version of unity, 86, 86b SphereCam, hierarchy, 85, 85f unity camera settings, 82, 83f viewing volume and LOD FPC, 142 instantCity.js file, 141, 142b visual effects, game's performance, 87 Canny edge detection, 402 Centroid technique, 307 Character mechanics artificial intelligence, 257–258 cellular automata cell status, 315–316 Game of Life, 315–317, 317f infinite 2D grid of cells, 315–316 SimCity, 315 decision trees attributes, 299, 300t 480 Black & White, 299 Boolean expression, 301 complex Boolean functions, 299, 305 decisionTree scene, 304 final eat decision with Food, 301, 302t graph, 304, 304f ID3 algorithm, 304 making and eating decision, 299, 300t map layout, 303 partial decision tree, 301, 301f RTS AI build decisions, 303, 303t rules, 305 terminal/leaf nodes, 299 tree node, 301, 302f flocking adding avoiding behavior, 296, 296b average speed, 295, 295b, 296 Batman Returns, 299 circular pattern, 296 close-streamed groups, 298 crowds/groups movement, 292 dramatic effect, 297 flock script, 293, 294b fly in set direction, 297, 297b fly to specific location, 298, 298b globalFlock script, 293 Random.Range, 295 rules, 293, 293f, 299 SeagullPrefab, 293 testFlock scene, 293 unparalleled simple algorithm, 293 wind value, 297 FSM (see Finite state machines) fuzzy logic classical sets, 305, 306f computational logic system, 305 definition, 305 degree of membership, 305 DotFuzzy engine, 307, 308, 311 fuzzyAI scene, 308 fuzzyBrain.js code, 308, 308b, 311 fuzzy rule, 306 fuzzy sets, 305, 306f, 310b, 311f Mamdani style, 306–307 NPC, 311 Sugeno style, 306 vague, ambiguous, inaccurate, and incomplete information, 305 vague terminology, 305 genetic algorithms binary sequence information, 314 biological evolution, 311–312 chromosomes, 312, 313 DNA sequences, 10 generations, 315, 316f evolutionary computing, 311–312 fitness values, 313 genes, 312, 313 maze configuration, 314, 315f maze layout, 314, 314f natural evolution, 311–312 NPC's DNA, 314–315, 315f organism, 312 procedure, 313b graph theory, 263–264 line of sight AI script code, 260b, 263b CanSeeTarget() and CanShoot() functions, 262 field of vision angle, 263 Hierarchy, 262 NPC and player, 258–260, 259f open chasingAI scene, 260 vectors, 259, 259f waypoints A* algorithm (see A* algorithm) BFS, 267–268, 267b, 268f DFS, 268, 268b, 269, 269f Euclidian distance, 266–267 heuristic function, 270 maze, 265, 265f paths, 265, 267 remembered map location, 265 utility, 266–267, 266f CityEngine software, 392 Conditional statements if-else statement Boolean algebra, 46 Boolean test, 49 condition statements, 48 example, 46, 46b fallandGrow.js file, 47, 47b, 48b JavaScript, 46, 46b shortcut arithmetic operations, 49b, 50t Index for loops aPrimitive (aP), 51 column and row of cubes creation, 52b, 53f local variables, 51 matrix of cubes creation, 52, 52b, 54f stackedSpheres.js file, 51, 51b Contrast, repetition, alignment, and proximity (CRAP), 333 D Defuzzification, 307 Depth-first search (DFS), 268, 268b, 269, 269f DFS see Depth-first search DotFuzzy, 307 E emailer.php Web emailer, 438, 438b emailViaServer JavaScript file, 436, 436b Environmental mechanics camera tricks Adobe Photoshop filters, 397–398 bloom effect, 398f, 401 blur effect, 398f, 399–400, 400f color correction, 398f, 402 crease effect, 398f, 402 depth of field, 399, 399f edge detection algorithm, 398f, 402 fish eye effect, 398f, 403 flares, 398f, 401–402 grayscale, 398f, 400 image processing and photographic postproduction, 397–398 motion blur, 398f, 400–401 sepia tone, 398f, 401 SSAO effect, 398f, 403–404 sun shafts, 398f, 403 twirl effect, 398f, 401 Unity camera effects, 397–398, 398f vignette effect, 398f, 403 visual effects, 397 game art assets, 363 map design 3D dimension, 371–372 detail, 366–367, 367f flow, 371 focal point, 364, 365f genre and game developers, 364 physical map layout (see Physical map layout) player's movement guide and restriction, 364–365 player starting position, 371 scaling, 365–366, 366f trapping, 371 vantage points, 372 outdoor landscape, 363–364 particle systems Animate Colors, 418 animated billboards, 416 chimney smoking particle effect, 418, 419f Collision Energy Loss, 421 2D billboard, 417 Ellipsoid Particle Emitter, 418 final snow scene, 421, 422f First Person Controller, 419, 420 fluidic and fuzzy phenomena, 416 Min and Max Emission, 418, 419–420 Min and Max Energy, 418, 420 Particle Animator component, 418 particlehit JavaScript file, 420, 420b puff effect, 420 snow fall, 419 snowflakes, 419, 420 SnowyRetreat scene, 417 Splat, 420, 421 Unity packages, 417 Unity's default particle system, 417, 417f velocity, 416, 416f World Particle Collider component, 421 skies blue background color, 404 clouds, 409–412, 410f, 411f Mie theory, 404 Rayleigh scattering, 404–405 skyboxes, 405–406, 405f sky domes, 406–409, 407f, 408f turbidity, 404–405 terrains (see Terrains) weather precipitation, 416 wind, 412, 413f, 414f Explicit teleports object setting, 360, 360f particle systems, 359 teleportTo.js file, 359, 359b External forces haptics and external motion EyeToy, PlayStation 2, 428 iPhoneUtils.Vibrate() code, 428 Kinect, 428, 429, 429b Nintendo Wii, 428 OpenKinect, 428 OpenNI, 428 sense of touch, 427–428 Stage System, 429 vibration, 427–428, 428b HCI technology, 423–424 mobile device (see Mobile devices) mobile hardware access (see Mobile hardware access) multiplayer modes, 424 platform deployment App Store and Android Market publishing, 475–476 console publishing, 476 download direct to player, 476–477 self-publicity and tenacity, 475 social mechanic APIs, 447 Facebook (see Facebook) OpenFeint (see OpenFeint) personalized 3D avatars, 447 plug-and-play functions, 447 Twitter (see Twitter) EyePet, 444 F Facebook, 424 ConnectToFacebook scene, 459, 460f embedding Unity game, 466b, 467f Facebook app, 459 GetUserFriends() function, 465 GetUserGroups() function, 465 Graph, 459 interface.js code, 460, 461b, 462, 462b, 465, 465b JSON-formatted data, 459 Magic Token, 459, 460, 460f, 461f profile picture, 463, 464b RequestUserDetails() function, 463 UFacebook.cs file, 465 481 Index Facebook (Continued) Web-based calls, 459 Web platform version, 466 XCode and Visual Studio programming, 459 Feedback factors consistency, 255 cost vs benefit, 255 immediacy, 255 saturation, 255 Finite state machines (FSM) automatic waypoint collection, 280, 280b bidirectional paths, 281 breadcrumb pathfinding, 288–289, 289b, 290, 290b code, 279, 279b currentNode, 281 directed graph, 277–278 directional light, 284 event value, 279 First Person Controller, 284, 287–289, 288f guard patrolling, 284 guard shoot and chase the player, 284, 284b guard shooting and pursuing actions, 287–288 heightOffset variable, 288 nondeterministic automata, 277–278 patrol script, 281, 282b, 290, 290b polySurface submesh, 284 robot model, 287–288 Start() function, 281 state transitions, 278, 278t state value, 279, 280 warehousePatrol scene, 280 waypoint tag, 280 First person controller (FPC), 384, 385f First person shooter (FPS), 258 Fog fog density property, 143 FPC, 143 visual size reduction, 143 Follow through blob.js file, 133, 133b cube as door, 132, 132f obstacles removal, 132 and overlapping action, 123 Frames per second (FPS), 19 FSM see Finite state machines Fuzzification, 306–307 482 G Game mechanics, programming game art asset primer people's art assets (see People's art assets) power of two rule (see Power of two rule) game engines generic game engine, 18–19 main game loop/main loop (see Main loop) lateralization, left side of brain, art creation color, 15–17 direction, 12–13 line, 10 point, 9–10 shape, 11–12 size, 13 texture, 13–15 misnomer, neuromyth stemming, 2–3 right side of brain Barnsley fern leaf transformations, 5, 6f, 7f getting started with processing, 9b logic, Mandelbrot set/Snowman, 5, 6f procedural/dynamic generation, procedural generation in unity, 7b programming languages, learning, 3–4 Umberto Eco, scripting primer arithmetic operators, 42 arrays (see Arrays) comments, 32–33 conditional statements (see Conditional statements) function, 33 grow.js file, 44, 44b interactive Boolean algebra logic gates, Web site, 31b logic circuit (see Logic circuit) objects (see Objects) relational operators, 43–45 revolve.js file, 44, 45b unity scripting reference, 45 variables (see Variables) side of brain, task, 2–3 GameObjects, definition, 23 Game rules and mechanics cause-and-effect nature, 205–206 developing with simple game mechanics avoidance and collecting (see Avoidance and collecting) matching and sorting (see Matching and sorting) racing (see Racing) searching (see Searching) shooting, hitting, bouncing, and stacking (see Shooting, hitting, bouncing, and stacking) game mechanics algorithms and data structures, 208 first person shooter game, 207 game mechanic cycle, 206, 207f game/player relationships, 206 paper-rock-scissors, 207–208 peripheral computing objects, 206 play, 205–206 primary mechanics avoidance, 213 capturing, 212 chancing, 210–211 collecting, 213–214 conquering, 212–213 decision-making activities, 208 matching, 209 mixing, 211 pattern matching, 208 progressing, 212 searching, 208–209 sorting, 209–210 timing, 211–212 rewards and penalties Behavior management techniques (see Behavior management techniques) feedback factors (see Feedback factors) operant conditioning, 252–253 player action vs game response matrix, 252, 253f player's behavior, 252 Index Gaussian blur effect, 399–400, 400f Global Positioning System (GPS) geocaching, 439 getGPS JavaScript code, 442, 442b location-based games, 439 My Grove, 441, 442f NAVSTAR system, 439 Parallel Kingdom, 441, 441f player's location, Unity iOS and Android, 441 position on earth, bouncing signals, 439 satellite data access, 443 Tourality, 439, 440f trilateration, 439, 440f GPS see Global Positioning System H Heads-up display (HUD) design, 328 edge definition, 333 feedback from game, 319–320 focus, 334 Heads-up display (HUD) radar system radar.js file, 250, 250b, 252 Radar script, 252 texture creation, 251–252 Human–computer interaction (HCI) technology, 423–424 I Implicit teleports cube game object, 357, 358f sewer model, 357 teleport.js file, 357, 358b teleportOutside.js file, 358b, 359 interface.js file, 434, 434b, 435b Inverse kinematics, 172–173 animationController.js file, 179, 179b animationController script, 180, 180b animationControls.js file, 176, 176b animationControls script, 174, 174b, 175, 175b, 177, 177b calculation, 173 degree of freedom, 173–174 IK1JointAnalytic.cs and IKSolver cs file, 179 ikSolver.Solve() function, 180 LateUpdate() function, 177 locomotion project link, 181 LookAt() function, 176 model bone attachment, script variables, 176, 176f problem solution, 173, 173f reverse operation, forward kinematics, 173 J JavaScript Object Notation (JSON), 449 L Law of gravity downward acceleration, 113 force of gravity definition, 112 gravity application gravity settings effects, 115 Rigidbody attachment, 114, 114f laws of planetary motion, 112 object downward speed, 113 unity's physics properties, 113, 113f Lightness method, 400 Lindenmayer system natural branching structure, 389 push and pop points, 390 remembered locations, 390, 391f rewriting, 389, 389f Sierpinksi triangle, 390, 391f square, 390, 390f street map and building progression, 392, 393f tree, 392, 392f Local and world coordinate systems rotation effects, 89, 89f transformations effect, local coordinates, 88–89, 88f Logic circuit Boolean algebra, 29, 30t Boolean function definition, 29 AND truth table, 29, 30t electric circuit, 28, 461f electronic switches, 28 interactive Boolean algebra logic gates, 31b logic gate configurations, 29 Luminosity algorithm, 400 M Main loop game objects, 20b games run, 19, 20f unity 3D development environment cube with spin script, 26, 27f multiwindowed editing environment, 22, 22f new material creation, 25, 25f single cube, scene, 23, 23f transformation, 24 unity editor interface navigation, 22b Matching and sorting Bejeweled and Solitaire, 214 clickndrag.js file, 223, 223b countBalls.js file, 225, 226, 226b, 231, 231b cube addition, 216, 217f destroyWhenGone.js file, 216, 217, 217b 2D screen coordinates and 3D world, difference, 221, 221f game object addition, 227, 227f initial setup, game, 216, 216f logical icons, 215 mainmenu.js file, 227–228, 228b material array, 220, 220f mesh collider attachment, 219, 219f new tag addition process, 223, 223f score.js file, 226, 226b, 230, 230b, 231 screen, viewport, and world vectors, 222b showScore.js file, 229, 229b, 230 spawn.js file, 217, 218, 218b, 219, 219b, 228, 229b stopBalls.js file, 224, 225b trigger collider, 225, 225f Midpoint displacement algorithm, 383 Mobile devices, 423 Android and iOS development, 424 Android Composite ADB Interface, 426 Android Interface, 424 Android SDK folder, 425 Applications, 425 Build Settings, 424, 425 Bundle Identifier field, 425 483 Index Mobile devices (Continued) com.yourname.TestApplication, 425, 426f Development, 425 directional light, 427 Google Android, 427 Hierarchy, 427 “No Android Device” error, 426 Player Settings, 425 Product Name, 425 screen display resolution, 426, 427f Switch Platform, 424 Unity Indy download, 424 Unity splash screen, 426 USB debugging and Stay awake options, 425 Mobile hardware access accelerometers acceleration axes, 430, 430f definition, 429 3D movement, 430 Input.acceleration, 430 JavaScript, 430, 431b microelectromechanical systems, 429 Nintendo Wii Remote, 429 Nunchuk, 429 PlayStation Dual Shock controller, 429 Spore Origins, iPhone version, 430 augmented reality cube positioning, marker, 445, 446f fiduciary marker, 444 high-quality animated virtual objects, 444 Image Target prefab, 445 marker setting, 445, 445f point of view (POV), 444 QCAR-1.0.unitypackage, 444 QualComm Unity Extension, 444 Unity running on Android, 445, 446f virtual game characters, 444 GPS geocaching, 439 getGPS JavaScript code, 442, 442b location-based games, 439 My Grove, 441, 442f NAVSTAR system, 439 Parallel Kingdom, 441, 441f player's location, Unity iOS and Android, 441 484 position on earth, bouncing signals, 439 satellite data access, 443 Tourality, 439, 440f trilateration, 439, 440f orientation, 431 Web services calling and retrieving URLs, 434b Parallel Kingdom, 433 sending emails via Web server, 436b sending emails with device mail client, 434b N Navigation System for Timing and Ranging (NAVSTAR) system, 439 NewBehaviourScript, 26 Newton's first law of motion add component function, 118 continue duplication and movement, cube stack, 116, 117f fire.js file, 117, 117b game object duplication, 116, 116f remove component, 116, 116f Newton's second law of motion addforce() function, 118 fire.js file, 118, 118b Newton's third law of motion bounce and friction, physics material, 120 physics material creation, 120, 121f physics material inspector view, 120, 122f physics materials demonstration, 120, 121f Ninento DS3D Nintendogs, 444 Nonplayer characters (NPCs), 257–259 Nonuniform rational basis spline (NURBS), 11, 11f NPCs see Nonplayer characters O Objects add component, game object, 60, 60b capsule, 58, 59f data type, class, 57 game object definition, 58b game object location, 59b instance, class, 57–58, 57f physics material modification, game object, 60, 60b spherePhysics.js file, 61, 61b variable exposure for bounciness, 62, 62b OpenFeint achievement IDs, 472, 472b, 474 achievement scores, 470 Android bundle identifier and package, 470, 471f AndroidManifest file, 470 Android Settings, 470 Application Information, 468, 469, 470, 471f authorization tokens, 468, 468f Build and Run, 473, 474f Build Settings, 470 Hierarchy, 469 IDs and keys, 472 iOS and Android APIs, 468 iPhone and iPad, 468 leaderboard IDs, 472, 472b, 474 mobile games, 468 OFInterface, 469, 469b, 470 OFObject, 469 OpenFeintController.cs, 470 Player Settings, 470 Plugins, 469 Submit Score button, 474 Unity integration package, 474 unlocked and locked achievements, 474 Opera Aperta, P People's art assets 3D models, 68, 69 fbx format, 69 model addition, Unity project, 69b Physical map layout branching level, 368f, 370 game level design structures, 368, 368f linear map, 368f, 369–370 logical and analytical structure, 367–368 open game map, 368–369, 368f perspective, narrative, and genre restrictions, 367–368 SimCity, 367–368 single game progression strategy, 368 spoke and hub structure, 368f, 370 Index Player mechanics facial expression, 319–320 game interface design principles best-designed HUD, 328 coherence, 331–332 feature exposure, 330–331 focus, 334 graphical user interface design, 328 help, 334 layout, 333 metaphor, 329–330 shortcuts, 332 state visualization, 332 user profiling, 328–329 game structure flowcharts, 320–321, 321f gamescenemenu.js file, 324, 324b GUI element, 326 GUI objects, 321b GUI Style component, 326, 326f Hover values, 327 mainmenu.js file, 323, 324b, 327, 327b mainmenu script, 326 Scenes in Build, 325, 325f Unity build settings and player settings, 322, 322f Unity game startup dialog box, 323, 323f heads-up display, 319–320 inventories attachPoint variable, 338, 339f box collider, particle system, 354, 355f character health status images, gui script, 352, 352f custom GUIStyle, 353, 353f Doom-like scenario, 337 duplicate doors, 349, 350f fire particle system, 354, 354f game genres, 337 gui.js file, 343, 343b, 345, 347, 347b, 351, 351b, 352, 353b image addition, key, 344, 344f inventory size restriction, 337 opendoor.js file, 342, 342b pickup.js file, 337, 338b, 340, 340b, 341b, 342, 342b, 345, 345b, 346, 346b, 347b, 349, 350b, 355, 355b, 356, 356b positioning values determination, 338, 339f wrench model, 338 wrench object assignment, 348–349, 349f physics engines, 319 status bar, 320 teleportation explicit teleports (see Explicit teleports) implicit teleports (see Implicit teleports) player's character movement, 357 visual representation, 320 Polygons and normals Blender, 3D model, 93, 94f 3D modeling package creation, 93 lighting effect calculation, 93, 94f normal definition, 93, 93f normal recalculation, 95, 96 Perlin function, 95–96 plane, 92 planes deformation, 95, 95f Power of two rule color depth definition, 64 graphical processing unit, 63 real-time animation, 63 textures, 64b, 65b Q Quake Arena (Q3A) game engine, 190 order and frame size, animations, 189, 189t partial animation configuration file, 190, 190t Quakebot, 189 three principal tags, model, 191 Quaternions attack.js file, 106–107, 107b, 108, 108b, 109b Destroy() function, 108 Euler angles, 101 gimbal lock, 101, 103f gyroscope, 101, 103f individual rotation, 3D space, 101, 102f message bar and console, 109, 110f moveBullet.js file, 105, 105b, 109, 110b, 111, 111b prefab creation, 106, 106f rescue Angle() function, 105 erratic orientations, rotations, 103–104, 104f Slerp() function, 105 storing orientations, 104 script variable, prefab value, 106–107, 107f R Racing against clock, 238 finishline.js file, 240, 240b nonplayer characters, 238 unaided human participants, 237 waypoints, addition and positioning, 238, 239f waypoint script, spheres addition, 239, 240f waypoints.js file, 239 Real-world mechanics animation physics and principles anticipation (see Anticipation) appeal, 124 arcs, 123 exaggeration, 123 follow through (see Follow through) secondary actions, 123 secondary motion (see Secondary motion) slow in and out, 123 solid drawing, 123–124 squash and stretch (see Squash and stretch) staging, 122 straight ahead action and pose to pose, 122 timing, 123 2D and 3D space definition camera (see Camera) local and world coordinate systems (see Local and world coordinate systems) polygons and normals (see Polygons and normals) translation, rotation, and scaling (see Translation, rotation, and scaling) 2D and 3D tricks, game space optimization Camera viewing volume (see Camera viewing volume) fog (see Fog) reducing polygons (see Reducing polygons) textures (see Textures) 485 Index Real-world mechanics (Continued) 3D game engine, 2D games Android and iOS, 96 applications, 96 attack.js file, 97, 97b finite state machine, 99 game object's name, inspector view, 97, 97f Move() function, 100–101 object attack and retreatment, 98, 98b object movement, 98, 98b one degree of freedom, 96 quaternions (see Quaternions) slerp addition, 99, 99b laws of physics first law of motion (see Newton's first law of motion) law of gravity (see Law of gravity) suspension of disbelief, 112 third law of motion (see Newton's third law of motion) principles of vectors dot product and cross product, 76 game environment, car model, 78, 79f normalized vector, 75–76, 75f pirate's treasure map, 74, 74f Pythagoras' theorem, 75 vector2 and vector3 class definitions, 79b vector mathematics, 73 Reducing polygons backface culling, 137 custom shader code, 137, 137b LOD, multiple models and textures, 138 simple LOD handler game statistics, 139, 139f LODManager.js file, 139, 140b superfluous polygons number, model, 136 Rule aggregation, 307, 307f Rule evaluation, 306–307 S Screen space ambient occlusion (SSAO), 398f, 403–404 Searching HUD radar system radar.js file, 250, 250b, 252 486 Radar script, 252 texture creation, 251–252 matching, 249 Secondary motion cloth object positioning, doorway, 134, 134f external and random acceleration, 135 interactive cloth, 136b life, 133 spec color and emissive color, 134–135 Shooting, hitting, bouncing, and stacking game engines, 232 mathematics programmed code, 232 real-world games, ball, 232 shooting aim.js file, 232–233, 233b, 234, 234b, 236, 236b Detonator.unitypackage, 235 explode.js file, 235, 235b strengthMeter.js file, 236, 236b trial-and-error environmental impact, 232 Single 2D sprite actions animated sprite sequences management class structures, variables, 184, 185f SpriteManagement.js file, 183, 183b, 184, 185b SpriteManager.js file, 186, 186b individual animation specifications, 182 texture atlas, animation frames, 182, 182f undesirable effect correction, frame location, 182, 183f Single-filed 3D animations Lerpz character, animated FBX file, 191, 191f multiple 3D animations management controls.js file, 192, 192b, 193, 193b CrossFadeQueued() function, 194 idle animation, 193 Lerpz character, animation addition, 192, 192f Q3A game engine, 190 order and frame size, animations, 189, 189t partial animation configuration file, 190, 190t Quakebot, 189 three principal tags, model, 191 skyDomeScript.cs file, 407, 407b Sony PlayStation Eye Toy, 444 Squash and stretch, 122 blob.js file, 126, 128, 128b bullet object squash, script, 129, 129b bulletObject variable, file.js file, 127, 128f fire.js file, 127, 127b first person controller, 125, 125f force multiplier, 127 FPC, 124 game-based physics engines, 124 isKinematic setting, 128 Newton's laws, 124 unity packages folder, 124, 125f wareHouseFBX, 126 Subtractive color model, 15–16 T Terrains definition, 372 drawing baking, 381, 382f basic terrain plan, 374, 375f Canada's Lake Louise photograph, 373, 373f changing water colors, 379, 380f created Lake Louise, 379, 381f Daylight Water prefab, 378 directional light, 373 First Person Controller, 378 Hierarchy selection, 373 import Character Controller package, 378 lightmapping, 379, 382, 382f Main Cameras Far Clipping Plane, 378 new project creation, 373 open Unity, 373 Pro version, 378 real-world image reference, 374, 375f sculpt and smooth, 376, 376f sculpting tool, 374 Index shadows, 379 Skybox package, 379, 380f terrain editor tools, 373, 374t texturing, 376, 377f tree painting, 377–378, 378f, 379f infinite terrain, 396 polygons, 372 procedural cities Character Controller package, 393 3D blocks, 392 directional light, 393 FPC, 393 fractals, 389 Hierarchy, 394, 395 Inspector, 395 iterations, 389, 390 L-system (see Lindenmayer system) makeCity.js file, 393–394, 394b, 395 map layout, 392 new Unity project, 393 Perlin Noise, 393, 394b, 395 Plugins, 393 procedural city generator, 392b procedurally generated city, 395, 395f push and pop points, 390 rules string, 389 scaling, 394 Sierpinksi triangle, 390, 391f skyscraper type building models, 395 Turbosquid, 393–394 turtle graphics, 390 procedural terrain bounding volume, 386 Character Controller package, 384 computer algorithm, 383 Diamond Square method, 383–384, 383f first person controller, 384, 385f fractals, 383 makeTerrain.js file, 385, 385b, 386, 386b, 387 Mesh Collider, 385, 386 midpoint displacement algorithm, 383, 383f Minecraft, 386 Perlin Noise, 384, 386, 387, 387b, 388, 388f plane's normals, 386 Plugins, 387 pseudo-random mathematical algorithm, 386 random function, 386 random height values, 388, 388f Render Clouds filter, 387, 388f Unity, 384 Unity Terrain, 387, 388f Textures billboards background scenery, fake, 146 billboard.js file, 146, 146b, 147, 147b blob shadows Blob Shadow Projector, 145 Male model, 145 processor light shadows generation, 145 moving textures animatedTexture.js file, 144, 144b LateUpDate() function, 144 Translation, rotation, and scaling rotate function, game object rotation, 91, 91f scaling, object size, 91, 92f scaling values, 92 translate function, 90, 90f translation definition, 90 Unity JavaScript, 91 Tweeter, 455, 458 Twitter, 424 account, 453, 454, 455 API, 447 API_KEY, CONSUMER_KEY and CONSUMER_SECRET, 453 Ashton Kutcher's tweets, 447, 447b authentication, posting messages, 449 authorization form, 453, 453f authorization process, 449 cyberspace, 447 Data in 3D, 455b human-readable text data interchange standard, 449 JSON format, 449 OnGUI function, 450, 450b personalized authority tokens, 449 personalized codes, 450 PIN number, 449, 453, 454, 454f PlayerPrefs functions, 451, 452 Plugins, 450 PostTweet code, 450 Start() function modification, 452, 452b SubmitPIN() function modification, 452, 452b Twitter posting form, 454, 455f TwitterPosting scene, 450 U Unity Scripting Reference, 45 UserTweets.js file, 455, 458 V Variables data types, 35 JavaScript variables private and exposed variables, 37, 38, 38f private keyword, 37 script linkage, 40, 40f Unity error message, 41, 42f variable declaration memory allocation, 35, 36f types, 35, 35b X XML and HTML Unity parser packages, 434 487 Preface About This Book I decided to write this book when I found existing literature for budding game designers, artists, and programmers tended to focus on only one specific vein of games development—that being a design, artistic, or programming book Those with artistic talents and ideas for games could not find a good resource to ease them into programming However, programming texts tend to be dry and ignore the visual aspect With the face of the game development industry rapidly changing from a small number of large development teams to much more of a cottage industry consisting of small multiskilled teams, it is more imperative that individuals are skilled in both art and programming Game development tools are also not what they used to be, and rapid game development tools such as Unity are making it a possibility for individuals to make complete games from scratch To address these issues, this book is written for the artist who wants to program and the programmer who wants some pointers about using game art In the beginning I started writing just for artists but soon came to realize the content was equally as relevant to those wanting to learn how to start programming games How This Book Is Organized This book has been written with artists who want to learn how to develop games and programmers who want to learn about using art in games in mind It approaches game development in a unique combination of teaching programming, keeping in mind the design; for programming, a game's graphical user interface is entirely different from making it look good Learning about how design impacts on programming and vice versa is a logical way to introduce both sides of the game develop coin to game creation All chapters focus on sets of mechanical functions existing within games: • • Chapter One, The Art of Programming Game Mechanics, explains the roles both art and programming play in creating games and explores the limitations of having one without the other In addition, the complementary nature of digital art and programming is established Chapter Two, Real-World Mechanics, examines the branch of physics dealing with the study of motion Motion is a fundamental idea in all of science that transcends the computer screen into virtual xi Preface • • • • • • xii environments This chapter examines kinematics, which describe motion, and dynamics, which examine the causes of motion with respect to their use in computer games It introduces the physical properties of the real world and demonstrates how a fundamental understanding of mathematics, physics, and design principles is critical in any game environment Composition, rules of animation, and design principles are introduced in parallel with technical considerations, mathematics, and programming code, which controls and defines the movement of characters, cameras, environments, and other game objects Chapter Three, Animation Mechanics, studies the technical nature of 2D and 3D animated models The reader will develop skills with respect to the programmatic control of their own artwork, models, and/or supplied assets in a game environment Elementary mathematics, physics, and programming concepts are introduced that demonstrate the concepts of keyframes, animation states, and development of dynamic character movement and sprite animation Chapter Four, Game Rules and Mechanics, introduces common generic game mechanics such as matching, sorting, managing, and hitting Examples of how each of these is represented visually in a game and the programming that controls them are explained in depth Common algorithms and data structures used for each mechanic are worked through with the reader integrating, where appropriate, key art assets Chapter Five, Character Mechanics, explains simple artificial intelligence algorithms to assist the reader in creating his or her own believable nonplayer characters Animation states and techniques covered in Chapter 3 are integrated with game-specific data structures and algorithms to control the behavior of characters from flocking of birds to opponents that follow and interact with the player Chapter Six, Player Mechanics, presents the code and artwork deployed to develop graphical user interfaces and maintain player states It includes details about the development of inventory systems, heads-up displays, and character–environment interaction Chapter Seven, Environmental Mechanics, reveals the fundamental concepts in creating and optimizing game environments It covers techniques from adding detail to environments to make them more believable to tricks for working with large maps and weather simulations Chapter Eight, Mechanics for External Forces, examines issues related to developing games while keeping in mind the new plethora of input devices, social data, GPS locators, motion sensors, augmented reality, and screen sizes Included is practical advice on using Unity to deploy games to iPhone, iPad, and Android mobile devices that leverage touch screens, accelerometers, and networking Preface The Companion Web Site The Web site accompanying this book is http://www.holistic3d.com It contains all the files referred to in the workshops, finished examples, and other teaching and learning resources Acknowledgments First I thank my editor, Sara Scott, who has kept my project on track Her encouragement and enthusiasm in the book have been highly motivational In addition, thanks must go to Mark Ripley of Effervescing Elephant Interactive who acted as technical editor and provided valuable insight on game programming with Unity Next, I acknowledge Unity3d who have developed a truly inspirational game development tool and all the forum contributors who have freely shared their ideas and code to answer all conceivable game development questions The forums at http://forums.unity3d.com are an invaluable knowledge base Finally, I thank my family, Daniel, Tabytha, Deefa (Labrador 15 years old), and Merlin (Labrador [...]... flicker 19 Holistic Game Development with Unity Initialize Process User Input Main Loop Process All Game Objects Process Components Update State Game Objects Update Game Objects Update Environment Clean up Render Scene Fig 1.17 How a game runs Unity Specifics Game Objects Game objects are the fundamental building blocks for Unity games It is through the addition, modification, and interaction of game. .. to a game object in Unity 21 Holistic Game Development with Unity Unity Hands On Getting to Know the Unity3 D Development Environment Step 1 To begin, download Unity by visiting http:/ /unity3 D.com/ and clicking on Download Unity has a free version that lacks some functionality, but never expires The free version is still quite powerful and is certainly enough for the first-time game developer Once... other colors can be created The color perceived by the human eye is the result of light being 15 Holistic Game Development with Unity Mesh Diffuse Map Texture Color (Diffuse) Map Normal Map Texture Normal Map Detail without Normal Map Diffuse & Normal Map Detail with Normal Map Fig 1.14 A soldier mesh with and without a color map and normal map reflected off the surface of the artwork When all of the light... write each game from scratch or modify older similar ones Eventually game editor programs started to surface that allowed developers to create games without having to write a lot of the underlying code The game engine takes care of things such as physics, sound, graphics processing, and user input, allowing game developers to get on with the creation of high-level game mechanics For example, in Unity, ... time, press the play button As you have not added any functionality at this stage when running, all the game will do is display a static cube 23 Holistic Game Development with Unity Note Unity allows you to edit your game as it is running This is great if you want to test out an idea to see how the game will react Be careful though because any changes you make in the editor, while play is on, will revert... generic game engine Physics AI Game Object Component Game Object Game Engine Physics Manager Sound Manager 18 Input Manager Graphics Sound The Art of Programming Mechanics In addition to these managers are game objects Game objects represent all the assets placed in a game environment These include the terrain, sky, trees, weapons, rocks, nonplayer characters, rain, explosions, and so on Because game. .. list) { } A function declaration begins with the keyword function, followed by its name and then a list of input values While functions are a programming element usually introduced to new programmers further down the track, they are fundamental to writing JavaScript code for Unity and therefore are being explained up front 33 Holistic Game Development with Unity Unity Specifics Functions Several essential... starting Unity, create a new project by selecting File > New Project Note the project name and directory used to save the project are one and the same; by default, this is “New Unity Project.” Step 4 To create a simple scene, select GameObject > Create Other > Cube from the main menu All objects added to a game scene are called GameObjects in Unity A cube will appear in the Hierarchy, Scene, Game, and... developing game mechanics and tying an entire game together In Unity, scripts added to game objects can be written in JavaScript or C# This book uses JavaScript, as it requires less background knowledge in programming to get started and the syntax is more forgiving than C# Physics Particles Mesh Audio Game Object Component Render Misc Game Object Scripts Fig 1.18 Components that can be added to a game object... mechanics For example, in Unity, physical 17 Holistic Game Development with Unity properties can be added to a ball with the click of a button to make it react to gravity and bounce off hard surfaces Driving these behaviors, embedded in the engine, are millions of lines of complex code containing many mathematical functions related to real-world physics The game developer can spend more time designing