derived from kirill muzykov’s rocket mouse tutorial @shahedc wakeupandcode.com
TRANSCRIPT
![Page 1: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/1.jpg)
By Shahed ChowdhuriSr. Technical Evangelist
Unity 2D: Step by Step, Part 3Derived from Kirill Muzykov’s Rocket Mouse Tutorialhttp://www.raywenderlich.com/69392/make-game-like-jetpack-joyride-unity-2d-part-1
@shahedC
WakeUpAndCode.com
![Page 2: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/2.jpg)
Slicing Sprite Sheets
![Page 3: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/3.jpg)
Select “Run” Sprite in Project panel
Select “Run”Sprite
![Page 4: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/4.jpg)
Set “Sprite Mode” to “Multiple”
![Page 5: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/5.jpg)
Click “Sprite Editor” Button
(Sprite Editor pops up!)
![Page 6: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/6.jpg)
Slice It!1. Click Slice dropdown
2. Set Type to “Grid”
3. Set Pixel Size• X = 156• Y = 156
4. Click Slice button
![Page 7: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/7.jpg)
Apply the Slice Click “Apply”
then, close popup
![Page 8: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/8.jpg)
Verify Run Sprites in Project Panel
Separate spritesfor each frame
![Page 9: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/9.jpg)
Creating Animations
![Page 10: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/10.jpg)
Click Window Animation
Click on Animation tab
![Page 11: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/11.jpg)
Create “Animations” Folder
Right-click Assets, click Create Folder Name it “Animations”
![Page 12: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/12.jpg)
Select “Cat” in Hierarchy
Select “Cat”
![Page 13: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/13.jpg)
Create New Animation
In Animation tab,
Click dropdown…
Create New Clip (twice)• run• fly
![Page 14: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/14.jpg)
Create Clips for “run” and “fly”
Save “run.anim“ Save “fly.anim“
![Page 15: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/15.jpg)
Verify Animations
Verify:• Cat animation• fly clip• run clip
![Page 16: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/16.jpg)
Verify Animator Component
Select “Cat”
Verify “Animator”
![Page 17: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/17.jpg)
Adding Run Frames
![Page 18: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/18.jpg)
Select “run” Animation
Click “run” animationin dropdown
![Page 19: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/19.jpg)
Expand “Run” Spritesheet
Expand “Run” animation in “Sprites” folder
![Page 20: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/20.jpg)
Select “Run” Frames
Click first frame, press Shift on your keyboard, click last frame
![Page 21: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/21.jpg)
Drag “Run” Frames into “run” Animation
Drag frames into “run” animation
![Page 22: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/22.jpg)
Adding Fly Frames
![Page 23: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/23.jpg)
Select “fly” Animation
Click “fly” animationin dropdown
![Page 24: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/24.jpg)
Expand “Fly” Spritesheet
Expand “Fly” animation in “Sprites” folder(notice that there’s only 1 frame)
![Page 25: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/25.jpg)
Select “Fly” Frames
Click Fly frame
![Page 26: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/26.jpg)
Drag “Fly” Frame into “fly” Animation
Drag frame into “fly” animation
![Page 27: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/27.jpg)
Stop Recording Animations
Click “red dot”recording iconto stop recordinganimations
(or just Save)
![Page 28: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/28.jpg)
Run the Game!
The cat runs like crazy!!!
Run
![Page 29: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/29.jpg)
Fixing the Animation
![Page 30: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/30.jpg)
Update “run” Animation Sample Value
Update “Sample” to 8
![Page 31: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/31.jpg)
Update Cat’s Animator Component
Uncheck Apply Root Motion
Change Update Mode to“Animate Physics”
![Page 32: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/32.jpg)
Run the Game!
The cat runs slower now, but is still running in the air!
Run
![Page 33: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/33.jpg)
Creating Transitions
![Page 34: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/34.jpg)
Click Window Animator
Click on Animator tab
![Page 35: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/35.jpg)
Create Transition…
Right-click “run” animation, then click “Make Transition”
![Page 36: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/36.jpg)
Complete Transition… From “run” to “fly”
Click “fly” animation to finish creating the transition
![Page 37: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/37.jpg)
Create Another Transition
Now, right-click “fly” animation, then click “Make Transition”
![Page 38: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/38.jpg)
Complete Transition… From “fly” to “run”
Click “run” animation to finish creating the transition
![Page 39: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/39.jpg)
Add Parameter
Click + next to Parameters (lower left of Animator tab)
Choose “Bool” (which is of type Boolean)Name it “grounded”
![Page 40: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/40.jpg)
Set Parameter Condition For “run” “fly”
Select run fly animation
Select “grounded” under Conditions
Set to “false”
![Page 41: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/41.jpg)
Set Parameter Condition For “fly” “run”
Select fly run animation
Select “grounded” under Conditions
Set to “true”
![Page 42: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/42.jpg)
Run the Game!
Optional: Check/uncheck “grounded”, then play the game to test the animations
Run
![Page 43: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/43.jpg)
Working with the Ground
![Page 44: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/44.jpg)
Create Empty Game Object
Verify new Game Object
![Page 45: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/45.jpg)
Drag GameObject into Cat, Rename It
Drag GameObject into “Cat”, verify that it is a child of “Cat”, rename to “GroundCheck”
![Page 46: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/46.jpg)
Set “groundCheck” Position
Set Transform Position for “groundCheck”• X = 0• Y = -0.7• Z = 0
![Page 47: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/47.jpg)
Select Icon and Color
Click icon symbol to select a color, e.g. green
![Page 48: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/48.jpg)
Verify “groundCheck” in Scene
Verify “groundCheck” game object
![Page 49: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/49.jpg)
Select Floor Inside Prefab
Expand “mount1” prefab, select “Floor”
![Page 50: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/50.jpg)
Add Layer…
In Inspector panel, click Layer dropdown to Add Layer…
![Page 51: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/51.jpg)
Enter “Ground” Layer
Enter “Ground” for User Layer 8
![Page 52: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/52.jpg)
Assign Floor to “Ground” LayerUpdate Layer to “Ground”
![Page 53: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/53.jpg)
Launch “CatController” Script
![Page 54: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/54.jpg)
Add Instance Variables
Add 4 instancevariables beforeStart() method
![Page 55: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/55.jpg)
Initialize Animator
Add 1 line of codeinside Start() method
![Page 56: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/56.jpg)
Add New Method to Update StatusAdd new method UpdateGroundedStatus
… just before class ends at the bottom
![Page 57: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/57.jpg)
Call Method to Update Grounded Status
Add 1 line of code
… just before FixedUpdate() ends
![Page 58: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/58.jpg)
Verify New Items
Select cat in Hierarchy
Verify 2 new public items under Cat Controller script
![Page 59: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/59.jpg)
Assign Ground Check Transform
With Cat selected…Drag “groundCheck”into Ground CheckTransform
![Page 60: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/60.jpg)
Assign Ground Check Layer Mask
With Cat selected…set Ground CheckLayer Mask to“Ground”
![Page 61: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/61.jpg)
Toggling the Flames
![Page 62: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/62.jpg)
Launch “CatController” Script
![Page 63: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/63.jpg)
Add Public Variable for Jetpack
Add 1 line of codejust before Start() method
![Page 64: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/64.jpg)
Add Method to Adjust Jetpack
Add new method AdjustJetpack()
… just before class ends at the bottom
![Page 65: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/65.jpg)
Call Method to Adjust Jetpack
Add 1 line of code
… just before FixedUpdate() ends
![Page 66: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/66.jpg)
Assign Ground Check Transform
With Cat selected…drag “jetpackFlames”into Jetpack
![Page 67: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/67.jpg)
Run the Game! Run
• The cat should run only while on the ground• The jetpack particles should only be visible while in the air
![Page 68: Derived from Kirill Muzykov’s Rocket Mouse Tutorial @shahedC WakeUpAndCode.com](https://reader037.vdocument.in/reader037/viewer/2022103022/56649cca5503460f94992364/html5/thumbnails/68.jpg)
End of Part 3