Unity 3.x Scripting


Unity 3.x Scripting
eBook: $23.99
Formats: PDF, PacktLib, ePub and Mobi formats
$20.39
save 15%!
Print + free eBook + free PacktLib access to the book: $63.98    Print cover: $39.99
$39.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Make your characters interact with buttons and program triggered action sequences
  • Create custom characters and code dynamic objects and players’ interaction with them
  • Synchronize movement of character and environmental objects
  • Add and control animations to new and existing characters
  • Written in simple and step-by-step format with real life examples, this book is the only one in the market to focus on Unity Scripting

 

Book Details

Language : English
Paperback : 292 pages [ 235mm x 191mm ]
Release Date : June 2012
ISBN : 1849692300
ISBN 13 : 9781849692304
Author(s) : Volodymyr Gerasimov , Devon Kraczla
Topics and Technologies : All Books, Game Development, Unity, Games

Table of Contents

Preface
Chapter 1: Diving into Scripting
Chapter 2: Custom Character Controller
Chapter 3: Action Game Essentials
Chapter 4: Drag-and-Drop Inventory
Chapter 5: Dynamic GUI
Chapter 6: Game Master Controller
Chapter 7: Introduction to AI Pathfinding and Behaviors
Appendix: Object-oriented Programming in Unity
Index
  • Chapter 1: Diving into Scripting
    • Downloading and installing assets for this book
    • Getting started with the game
    • Available Character Controllers
    • Interactive objects
      • Triggers
      • Buttons
        • Base button script
        • Activating platform status
      • Explosion box
        • The Update function
        • The BOOM function
      • Downloading the Detonator package
        • Pressing the button
    • Dynamic objects
      • Moving boxes
      • Triggered object
      • Moving platform
      • Moving the character with the platform
    • Summary
    • Chapter 2: Custom Character Controller
      • Creating a controllable character
      • Custom Character Controller
        • Setting up the project
        • Creating movement
          • Manipulating character vector
          • Register input from the user
          • The Rigidbody component
        • Jumping
          • User input verification
          • Raycasting
          • Additional jump functionality
        • Running
      • Cameras
        • Camera scripting
          • Creating camera script
          • Creating an enumeration list
          • Writing functions
          • Writing camera switching controls
          • Character movement and camera positioning
          • Updating camera type changing
          • Influencing camera with a mouse
          • Clamping angles
          • Camera's late update
          • Rotating character with a camera
      • Animation controls
        • Playing simple animations
          • Start function versus Awake function
          • Animation component and playing speed
          • Animation scripting
          • Walk, run, and idle animations
      • Summary
      • Chapter 3: Action Game Essentials
        • Programming weapons and pickables
          • Creating the base
          • Programming the weapon
            • The Shooting function
            • Shooting cooldown
            • Alternative shooting function
        • Advanced animation system
          • Working of an animation
            • Animation mixing
            • Animation script overview
        • Weapon pickup
        • Adding ammo and health pickups
        • Creating a treasure chest
        • Applying projectile fixes
        • Tethering and soft body
          • Tethering
            • Creating a tether
          • Creating assets
            • Tether manager
            • Creation of tether
            • The StickySegment script
            • Tether scripts overview
        • Summary
        • Chapter 4: Drag-and-Drop Inventory
          • GUI basics
            • GUI.Box
            • GUI.Button
            • GUI.Label
            • GUI.TextField
            • GUI.TextArea
            • GUI.Toggle
            • GUI.Toolbar and GUI.SelectionGrid
            • GUI.HorizontalSlider and GUI.VerticalSlider
            • GUI.HorizontalScrollBar and GUI.VerticalScrollBar
            • GUI.BeginGroup and GUI.EndGroup
            • GUI.BeginScrollView, GUI.EndScrollView, and ScrollTo
            • Other GUI classes
          • Drag-and-drop inventory
            • Basics
            • Inventory slots and draggable objects
            • Working with GUI windows
            • Inventory slots
            • Patching the inventory
          • Character customization
            • 3D character avatar
              • Dealing with a camera
              • Adjusting the camera
              • Window dragging limits
            • Customization
              • Setting up items
              • Adding items
              • Modifying character
              • Reloading and inventory
              • Finishing adjustments
          • Summary
          • Chapter 5: Dynamic GUI
            • Radial health display
              • The Health script
              • Health display script
              • Revisiting the Health script
              • Hooking up objects to Inspector
            • Creating items
              • The Change_Item script
                • Setting up the code
                • Changing items
                • Addition and removal
                • Displaying items
                • Increment controls
              • Creating the UseItem script
              • Revisiting the Change_Item script
              • The PlayerStats script
              • The TextManager script
              • The textMesh script
              • Revisiting the UseItem script
              • Revisiting the Health script
            • Creating armor
              • The Armor script
              • Revisiting the HealthBar script
              • Revisiting the Health script
              • Revisiting the UseItem script
            • Creating the weapons
              • The Change_Weapon script
              • The UseWeapon script
              • Revisiting PlayerStats
              • Revisiting the textMesh script
            • Scripting and displaying the score system
              • The Score script
                • Reading from the text file
                • Writing to the text file
              • The timer script
              • Revisiting the textMesh script
            • Displaying the objectives
              • Revisiting TextManager
              • Revisiting textMesh
              • Hooking up HUD
              • Game manager
              • Health
              • Item_Pic
              • ItemMultiplier, highScoreDisplay, ObjectiveDisplay, scoreDisplay, and weaponDisplay
              • saveDisplay
              • Weapon_Pic
            • Creating the targeting system
              • Creating the Bezier equation script
              • ArcBehaviour
              • The moveObject script
              • Hooking it up in the editor
            • Summary
            • Chapter 6: Game Master Controller
              • Game manager theory
              • Creating game managers
                • Level streaming
                • Mission creation
                • Managing levels
                • Save/load system
                • Loading with checkpoints
              • GameLoader
              • Dynamic camera
              • Audio
              • Audio manager
              • Summary
              • Chapter 7: Introduction to AI Pathfinding and Behaviors
                • Simple waypoint pathfinding
                  • Setting up the hierarchy
                  • Writing the waypoint display script
                  • Setting up the path arrays
                  • Creating the aiSimplePath script
                    • Declaring variables
                    • Starting up functions
                    • Traversing the path
                    • Shutting down the robot
                    • Hooking up the aiSimplePath script on Inspector
                • Enemy statistics, shooting, and behaviors
                  • The enemyStats script
                    • Setting up variables
                    • Setting up functions
                    • Retrieving functions
                    • Manipulation functions
                    • Hooking up the enemyStats script on Inspector
                  • The Shoot script
                    • Setting up the script
                    • Writing shooting functionality
                    • Hooking up the Shoot script on Inspector
                  • The aiSimpleBehaviour script
                    • Setting up the script
                    • Behavior functions
                    • Additional functions
                    • Hooking up the aiSimpleBehaviour script on Inspector
                • Returning to the aiSimplePath script
                  • Pursue functionality
                  • Revisiting the EnemyPath function
                • The bulletCollision, ammoCollision, and AmmoInfo scripts
                  • Creating the bulletCollision script
                    • Hooking up the bulletCollision script on bullet's Inspector
                  • Creating the ammoCollision script
                    • Hooking up the ammoCollision script on enemy's Inspector
                  • Creating the AmmoInfo script
                    • Hooking up the AmmoInfo script on ammo's Inspector
                • Summary

                  Volodymyr Gerasimov

                  Volodymyr Gerasimov is a Level Designer and Scripter. His major passion is creation of modifications for popular games and developing small indi projects, with scripting as a main tool. He learned various scripting and programming languages in The Art Institute of Vancouver. Having been introduced to Unity in 2010 he created and worked on a number of projects, indi games and prototypes. Latest one was hack and slash action game Splik & Blitz: Baked in blood, where he worked as Lead Level designer and Scripter. Right now he is working on a couple of indi projects for iOS and PC.

                  Devon Kraczla

                  Devon Kraczla is an independent Game Developer. Having an artistic background Devon came to the gaming industry to explore new ways to surprise people with his creations. Over the last few years, having graduated from The Art Institute of Vancouver, Devon developed multiple independent projects, both solo and with other enthusiasts. In his games Devon focuses on simple and engaging game mechanics covered in unique art style that makes his games appealing for hardcore and casual audiences. Currently Devon is working on a new project in a large group of passionate developers.
                  Sorry, we don't have any reviews for this title yet.

                  Code Downloads

                  Download the code and support files for this book.


                  Submit Errata

                  Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                  Errata

                  - 6 submitted: last submission 14 Dec 2012

                  Errata type: Typo | Page number: 14 | Errata date: 28 June 12

                  Check 6th line of 2nd code snippet: initPos = transform.position;

                  This is wrong. It should read: initPos = transform.localPosition;

                   

                  Errata type: Typo | Page number: 15 | Errata date: 28 June 12

                  On the 10th line of this page, there is a line of code "if(trigObj.getComponent(Button).ReturnButtonStatus();){". The semi-colon at the end of this line is wrong. It should be deleted.

                   

                  Errata type: Typo | Errata date: 09 July 12

                  Check for the instances of word "Boolean" :

                  Page no. 13: 3rd line under the "Activating platform status" heading

                  Page no. 14: 27th line: "var isPressed : Boolean = false;"

                  Page no. 24: 2nd line under 7th numbered bullet

                   

                  All these instances are wrong. The word "Boolean" should be replaced by "boolean".

                  Errata type: Typo

                  Check the instances of the word "could":

                  Page no. 13: "The following is an example of what it could look like:"

                  Page no. 14: "You have finished writing the base Button script. The following is a sample of what
                  that script could look like:"

                  This is wrong. It should be replaced by "should".

                  Errata type: Code

                  Check the second line of the code snippet on page number 47:

                  ChangeCamValues();

                  This should be changed to ChangeCamType();

                   

                  Also, find the last line of same code snippet:

                  SetCameraValues();

                  This should be changed to SetCamValues();

                   

                  Errata type: Code

                  Check the second line of the code snippet on page number 48:

                  If(Input.GetKeyDown(KeyCode.T){

                  This should be changed to if(Input.GetKeyDown(KeyCode.T)){

                  The parenthesis is missing at the end.

                   

                  Sample chapters

                  You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                  Frequently bought together

                  Unity 3.x Scripting +    Unity Shaders and Effects Cookbook =
                  50% Off
                  the second eBook
                  Price for both: €29.90

                  Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                  What you will learn from this book

                  • Use available scripts that readers can use to create default character controller
                  • Attach default character controller scripts to an existing game object
                  • Set-up your own camera and character controller rigs through code
                  • Code dynamic and static objects like bio gun, ammo, health, character stat augmentation, treasure chests and make your character interact with them
                  • Create character item slots along with inventories, where players will be able to drag and drop different item icons in the inventory slots
                  • Attach existing animation scripts to characters and objects and create new ones
                  • Assign and equip selected items on a player or object, making them active and useable like adding fire functionality to a bio gun
                  • Create and maintain scores to control character objectives and save game data
                  • Setup a system to control transition between scenes and transferring objects from one scene to another along with instantiation for characters
                  • Deal with 2D and 3D parallax backgrounds
                  • Create an audio game controller to fix sound overlapping and create background audio stems
                  • Basics of enemy AI, such as path-finding and creating distinct enemy behavior and their awareness

                   

                  In Detail

                  Unity is a powerful tool for anyone who aspires to build interesting and sellable games. One of the exciting aspects of Unity is how easily it can be extended to build custom characters and game environments. Scripting is the key to accomplish all this, but it comes with a steep learning curve.

                  This book will teach you everything you need to know about scripting in Unity. It will take you through creating, including and tweaking scripts for achieving various tasks. Some of these tasks include controlling characters, animations, controlling objects, handling game data and enemy AI.

                  The book will begin by building scripts for simple tasks and continue to develop them for increasing level of difficulty. The first few chapters include scripting to build a custom game environment and creating characters and controlling them. Arranging camera views, controlling and creating animations are covered in the next set of chapters.

                  The book then moves on to build objects, animate them and code character interaction with them and create inventories where the characters can pick ammo, health and other such objects. Towards the end, the book teaches how to add background sound and discusses basic enemy AI scripting.

                  Approach

                  The book is written in an easy to understand step-by-step style. It covers real-world examples for every topic, so that you gain most out of the book and are able to apply these techniques straight into your game.

                  Who this book is for

                  If you are a programmer interested in developing games using Unity and want to customize your game by writing scripts, then this is a book for you. To make the best use of this book, you will have to know your way around Unity. The book is ideal for someone, who has experience in building games using Unity and knows a bit of programming; especially JavaScript. However, if you are a programmer in any other language, you should be able to grasp the book fairly easily.

                  Code Download and Errata
                  Packt Anytime, Anywhere
                  Register Books
                  Print Upgrades
                  eBook Downloads
                  Video Support
                  Contact Us
                  Awards Voting Nominations Previous Winners
                  Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                  Resources
                  Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software