Join Kelley Hecker for an in-depth discussion in this video Making a coin float, part of Scripting Unity with C#.
- Now that the coins are spinning,…I think they should also hover…up and down a bit.…I've gone ahead and added a few more coins…to my scene as well.…Remember that if you're starting directly…from the exercise files instead of continuing…from the previous video, you'll need to import…the standard assets for Unity 4.6 package…from the asset store and drag in…the ThirdPersonCharacter…and FreeLookCameraRig pre-fabs…like we did earlier in this chapter.…Go ahead and open the Coin script.…To make the coin float,…rather than modifying the coin's rotation,…this time I'm going to modify its position.…
We'll add two new variables.…The first one, floatSpeed,…will control how fast the coin moves up and down.…This will be in up and down cycles per second.…The second variable, movementDistance,…will be the maximum distance the coin can move…up and down from its center point.…
Both of these will appear in the inspector…because we used SerializeField…before the declaration.…I'm also going to add two private variables…that don't need to appear in the inspector…
- 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
Advanced Unity 3D Game Programmingwith Michael House3h 45m Advanced
Creating Mobile Games with Unitywith Kelley Hecker1h 12m Intermediate
1. Your First Script
3. Built-In Unity Classes
Picking up coins4m 8s
5. Events and Delegates
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.