Unity Game Development Scripting
eBook - ePub

Unity Game Development Scripting

Kyle D'Aoust

Share book
  1. 202 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Unity Game Development Scripting

Kyle D'Aoust

Book details
Book preview
Table of contents
Citations

About This Book

The intuitive and powerful Unity game engine is one of the most widely used and best loved packages for game development. Unity scripting is an essential but challenging skill to master in order to create custom game elements. Learning modular scripting allows you to rewrite as little code as possible as you deploy your scripts to multiple projects and work easier, quicker, and more efficiently than before.

In each chapter of this book, you'll learn how to script new game elements. Beginning with making custom controls for the keyboard and mouse, as well as the Xbox 360 Controller, you'll then get to grips with more complex systems such as inventory, data saving, and artificial intelligence. As you create these elements, you'll also learn how to make your scripts simpler and easy to use. This will allow drag-and-drop deployment, which is to be used by designers and nonprogrammers. Finally, you'll combine all of your newfound skills to create your own complete game project.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Unity Game Development Scripting an online PDF/ePUB?
Yes, you can access Unity Game Development Scripting by Kyle D'Aoust in PDF and/or ePUB format, as well as other popular books in Computer Science & Entreprise Applications. We have over one million books available in our catalogue for you to explore.

Information

Year
2014
ISBN
9781783553631
Edition
1

Unity Game Development Scripting


Table of Contents

Unity Game Development Scripting
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Interactive Input
Picking the controls
Mapping the needed controls
Checking the input manager
Checking the Xbox 360 Controller inputs
Adding additional controller inputs
Adding a start button and trigger inputs
Adding directional pad inputs
Adding PC control inputs
Housing our control script
Creating and naming the script
Formatting the script
Creating the device detector
Adding the variables needed
Creating the detection function
Creating the identifier function
Let's get set and show them
Adding variables for each control
Adding a function to display the variables
Let's switch!
Creating control profiles
Adding a profile switching function
Adding the GUI interaction function
Customization is key
Swapping control schemes
Adding a control switch button to the GUI
Cycling control inputs
Adding the controls pop up to the GUI
Resetting the controls
Adding the Reset function
Adding the Reset input
Playtesting
Summary
2. GUI Time
A traditional 2D UI
Setting up our scene
Housing our 2D UI
Creating GUI buttons
Creating a health bar
Level counter
Creating an experience counter
Housing our 3D UI
Creating a 3D health bar
Creating 3D damage reports
The new Update function
Completing the damage reports
Creating 3D name tags
Summary
3. Expandable Item Classes
The self item class
Adding our variables
Buff or debuff stats
The health changer
The armor changer
The item activator
The melee item class
Adding our variables
Buff or debuff stats
The health changer
Let's interact with the environment
Detecting triggers
The projectile item class
Adding our variables
Buff or debuff stats
The health changer
Adding movement
Detecting triggers
Playtesting
Summary
4. Inventory
Features of an inventory
Limits of the inventory
Accessing the inventory
Organizing an inventory
Item count modifications
Item bartering
Dropping and picking up items
Destroying and using items
Displaying the inventory
Creating the inventory script
Creating and naming the script
Adding the necessary variables
Initializing our inventory
Creating the initializer
Adding items
Let's figure this out
Creating the adding function
Removing items
Let's figure this out
Creating the removing function
Setting the quick-select items
Setting the quick-select items quickly
Let's display the inventory
Using our custom inputs
Displaying the GUI
Running the GUI
Playtesting
Creating a test scene
Let's add an item
Let's remove some items
Other things to try out
Summary
5. Enemy and Friendly AIs
AI techniques
Finite state machines
The behavior tree form of the AI system
Combining the techniques
Let's start scripting!
Internal and external actions
External actions
Internal actions
Scripting the actions
Pathfinding
Creating paths using the waypoint system
Unity's NavMesh system
Setting up the environment
Creating the NavMesh
Adding our variables
Scripting the navigation functions
Character animations
Importing the model mesh
Scripting the animations
Putting it all together
Final coding touches
Filling out the inspector
Playtesting
Summary
6. Keeping Score
Prototype stats
Assigning the stats to the player
The stat tracker
Setting the stats
Resetting the stats
Resetting all of our prefs
Saving all of our prefs
Setting a specific pref
Resetting a specific pref
Showing our stats on the screen
The achievement system
Prototyping the achievements
Adding the required achievement variables
Resetting the achievements
Achievement trackers
Tracking the kills
Tracking the gold total
Tracking the gold spent
Tracking the player's level
Tracking the rounds won
Tracking the time played
Let's check the achievements
Checking a specific achievement
Checking all of the achievements
Displaying the achievements on screen
Adding the GUI functions
Playtesting
Summary
7. Creating Save and Load Systems
Saving data with flat files
Adding the required variables
Time to save our file
Deleting our flat files
Loading our flat files
Time to load our file
The XML save system
Creating our XML files
Saving data with XML
Adding the required variables
Saving the player data
Saving the enemy data
Loading data with XML
Loading the player data
Loading the enemy data
Creating the SaveHandler script
The checkpoint system
The save anywhere-anytime system
Playtesting
Summary
8. Aural Integration
Background music
Creating a random system
Adding a playlist system
Implementing the audio systems
Atmospheric sounds
Creating the script and variables
Initializing the variables
Playing the atmospheric sounds
Sound effects
Creating the script and variables
Playtesting
Summary
9. Game Settings
Figuring out what to optimize
Making video configurations
Setting the values
Toggling the shadows
Setting the field of view
Setting the resolution
Toggling the anti-aliasing property
Setting vsync
Changing the quality settings
Loading the settings
Making audio configurations
Setting the values
Configuring the volumes
Setting the speaker mode
Creating the settings menu
Preparing the code
Creating the GUI
Saving all the values
Loading all the values
Playtesting
Summary
10. Putting It All Together
Creating levels
The main menu
The playable level
Creating player interactions
Shooting and pausing
Collecting potions
Adding all the sounds
Playing the background music
Adding the atmospheric sounds
Implementing the GUI ...

Table of contents