Join Kelley Hecker for an in-depth discussion in this video Modifying the coin prefab, part of Unity: Scripting with C#.
- Let's make use of some of the built-in classes…to create a coin object.…If you're starting from the Exercise Files…instead of continuing from the previous video,…remember that you'll need to import…the Standard Assets for Unity 4.6 package…from the Unity Asset Store,…and drag in the third-person character…and a free look camera rig prefabs…like we did in the previous video.…In the Exercise Files, there's already a Coin Prefab…in the Prefabs folder,…but it doesn't have a script attached to it.…In the top-level Assets folder,…go ahead and create a new folder and call it Scripts.…
Inside that folder, create a new C# script called Coin.…Double-click on the script to open it in MonoDevelop.…I'm going to create a Coroutine called Spin,…which will make the coin spin around.…You could also do this in Update,…but I'm going to use a Coroutine…so you can see how to write one.…Since I'm not using the Update function,…I'm going to remove it.…All Coroutines must have the return type IEnumerator.…
I want the coin to rotate smoothly,…
- Defining classes and variables
- Attaching scripts to objects
- Understanding MonoBehaviour class
- Using the Unity Scripting API
- Importing assets
- Using a singleton pattern to manage game state
- Creating an event
Skill Level Intermediate
Q: Why am I getting a script compile error when trying to load the exercise files?
A: This course was recorded in Unity 4.6, and Unity has since released Unity 5. There are two items to address for Unity 5 users.
Q: Why can't I see the Render Settings option in the Edit menu?
A: The Render Settings options have been moved in Unity 5. You can access them by going to the Window menu and choosing Lighting. In the window that loads, Render Settings can be found under the Scene tab.