Book Image

Mastering Unity 2D game development

By : Simon Jackson
Book Image

Mastering Unity 2D game development

By: Simon Jackson

Overview of this book

Table of Contents (21 chapters)
Mastering Unity 2D Game Development
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Overview
Index

Understanding components


Components in Unity are the building blocks of any game; almost everything you will use or apply will end up as a component on a GameObject inspector in a scene.

Until you build your project, Unity doesn't know which components will be in the final game when your code actually runs (there is some magic applied in the editor). So, these components are not actually attached to your GameObject inspector but rather linked to them.

Accessing components using a shortcut

In most Unity examples, you are shown how to access components through scripts by using shortcuts to the MonoBehaviour class that the game object inherits from. Accessing the components with the help of the following code:

this.renderer.collider.attachedRigidbody.angularDrag = 0.2f;

Tip

If you need any help with this title or have any suggestions on it, join in on the support forum for the book at http://bit.ly/MasteringUnity2DForums. The forum will also keep you updated on any announcements on the title, so...