Top Banner
Derived from Kirill Muzykov’s Rocket Mouse Tutorial http:// www.raywenderlich.com/69392/make-game-like-jetpack-joyride-unity-2d-part-1 @shahedC WakeUpAndCode.com
67

Ninja Cat Flyer - 1 of 6

Jul 15, 2015

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ninja Cat Flyer - 1 of 6

Derived from Kirill Muzykov’s Rocket Mouse Tutorial

http://www.raywenderlich.com/69392/make-game-like-jetpack-joyride-unity-2d-part-1

@shahedC

WakeUpAndCode.com

Page 2: Ninja Cat Flyer - 1 of 6

Getting Started

> Adding the Player

> Adding Code

> Ups & Downs

Effects & Objects

Page 3: Ninja Cat Flyer - 1 of 6
Page 4: Ninja Cat Flyer - 1 of 6

http://wakeupandcode.com/public_downloads/ms-UnityGameDev-ShahedChowdhuri-Meetup-2014-06-11.pptx

http://WakeUpAndCode.com/u

http://cdn4.raywenderlich.com/wp-content/uploads/2014/03/RocketMouse_Unity_Resources.zip

Page 5: Ninja Cat Flyer - 1 of 6

… then, click “Create”

Enter project location (empty folder)

… Select 2D…

Page 6: Ninja Cat Flyer - 1 of 6

Verify 2D in

Inspector

Click Edit Project Settings Editor

Page 7: Ninja Cat Flyer - 1 of 6

Select

“Main Camera”

in hierarchy

Verify

Transform

Position

(0, 0, -10)

Verify

“Orthographic”

Projection

Page 8: Ninja Cat Flyer - 1 of 6

In Project panel,

right-click

“Assets”

folder

Click Create, then Folder

Name it “Scenes”

Page 9: Ninja Cat Flyer - 1 of 6

Click File Save Scene

Name your scene, click Save

Inside “Scenes” subfolder…

Page 10: Ninja Cat Flyer - 1 of 6

1. In the Game panel…

2. Click the list of dimensions

3. Click [+] to “Add New Item”

1

2

3

1. Label it “Landscape”

2. Width & Height = 1136 x 640

3. Click OK.

Page 11: Ninja Cat Flyer - 1 of 6

Select Main Camera

in Hierarchy

Update Size to 3.2

Page 12: Ninja Cat Flyer - 1 of 6
Page 13: Ninja Cat Flyer - 1 of 6

Drag to Assets

Page 14: Ninja Cat Flyer - 1 of 6

Audio and Sprites

subfolders

Page 15: Ninja Cat Flyer - 1 of 6

Drag into Scene

Page 16: Ninja Cat Flyer - 1 of 6

Right-click

“Fly”

then click

Rename

Name it

“Cat”

Page 17: Ninja Cat Flyer - 1 of 6

Select “Cat”

in the

Hierarchy

In the Inspector panel,

update Position:

• X = 0

• Y = 0

• Z = 0

Page 18: Ninja Cat Flyer - 1 of 6

Click “Add Component” Physics 2D Circle Collider 2D

Page 19: Ninja Cat Flyer - 1 of 6

In the Inspector panel,

update Radius

for Circle Collider 2D

• Radius = 0.5

Page 20: Ninja Cat Flyer - 1 of 6

Click “Add Component” Physics 2D Rigidbody 2D

Page 21: Ninja Cat Flyer - 1 of 6

In the Inspector panel,

check “Fixed Angle”

Page 22: Ninja Cat Flyer - 1 of 6

The cat falls down!

Run

Page 23: Ninja Cat Flyer - 1 of 6
Page 24: Ninja Cat Flyer - 1 of 6

Right-click Assets, click Create Folder Name it “Scripts”

Page 25: Ninja Cat Flyer - 1 of 6

Right-click Scripts, click Create C# Script Name it “CatController”

Page 26: Ninja Cat Flyer - 1 of 6

Drag Script

to Cat

Verify Script Component

Page 27: Ninja Cat Flyer - 1 of 6

Click Edit Preferences Under External Tools, select your Script Editor

e.g. MonoDevelop or Visual Studio

Tip: Browse for devenv.exe in your Program Files folder if you don’t see Visual Studio

Page 28: Ninja Cat Flyer - 1 of 6

Double-Click Script Name

Page 29: Ninja Cat Flyer - 1 of 6

Script should launch in MonoDevelop or Visual Studio

Page 30: Ninja Cat Flyer - 1 of 6

Class Begins {

} Class Ends

Page 31: Ninja Cat Flyer - 1 of 6

} Class Ends

Page 32: Ninja Cat Flyer - 1 of 6

From top menu, click File Save

Or, click Ctrl S on your keyboard.

Page 33: Ninja Cat Flyer - 1 of 6

Make the cat jump up as it falls!

Run

Page 34: Ninja Cat Flyer - 1 of 6
Page 35: Ninja Cat Flyer - 1 of 6

Update Gravity

• X = 0

• Y = -15

Click Edit

Project Settings

Physics 2D

Page 36: Ninja Cat Flyer - 1 of 6

Does the cat stay down with more force?

Run

Page 37: Ninja Cat Flyer - 1 of 6
Page 38: Ninja Cat Flyer - 1 of 6

Click “Game Object” Create Empty Verify Game Object

in Hierarchy

Page 39: Ninja Cat Flyer - 1 of 6

In Hierarchy tab,

• right-click empty Game Object

• click Rename

• name it “Floor”

Page 40: Ninja Cat Flyer - 1 of 6

With Floor selected in Hierarchy:

• Update Transform properties:

• Position:

• X = 0

• Y = -3.5

• Z = 0

• Scale:

• X = 14.4

• Y = 1

• Z = 1

Page 41: Ninja Cat Flyer - 1 of 6

Click “Add Component” Physics 2D Box Collider 2D

Page 42: Ninja Cat Flyer - 1 of 6

Green Box Collider for FloorFloor is selected

in Hierarchy

Page 43: Ninja Cat Flyer - 1 of 6

Click “Game Object” Create Empty Verify Game Object

in Hierarchy

Page 44: Ninja Cat Flyer - 1 of 6

In Hierarchy tab,

• right-click empty Game Object

• click Rename

• name it “Ceiling”

Page 45: Ninja Cat Flyer - 1 of 6

With Floor selected in Hierarchy:

• Update Transform properties:

• Position:

• X = 0

• Y = 3.7

• Z = 0

• Scale:

• X = 14.4

• Y = 1

• Z = 1

Page 46: Ninja Cat Flyer - 1 of 6

Click “Add Component” Physics 2D Box Collider 2D

Page 47: Ninja Cat Flyer - 1 of 6

Green Box Collider for FloorBoth are selected

in Hierarchy

Green Box Collider for Ceiling

Page 48: Ninja Cat Flyer - 1 of 6

The cat should stop at the ceiling and floor!

Run

Page 49: Ninja Cat Flyer - 1 of 6
Page 50: Ninja Cat Flyer - 1 of 6

Click “Game Object” Create Other Particle System

Page 51: Ninja Cat Flyer - 1 of 6

Verify Particle System

in HierarchyVerify Particle System

in Scene

Page 52: Ninja Cat Flyer - 1 of 6

Verify Particle System

is a child of Cat

Drag Particle System

to Cat in Hierarchy

Page 53: Ninja Cat Flyer - 1 of 6

Right-click

“Particle System”

then click

Rename

Name it

“jetpackFlames”

Page 54: Ninja Cat Flyer - 1 of 6

In the Inspector panel for jetpackFlames, update:

• Transform:

• Position:

• X = -0.62

• Y = -0.33

• Z = 0

• Rotation:

• X = 50

• Y = 270

• Z = 270

• Particle System

• Start Lifetime = 0.5

• Start Size = 0.3

• Start Color:

• RGB = 255, 135, 40

• Emission

• Rate = 300

• Shape

• Shape = Cone

• Angle = 12

• Radius = 0.1

• Random Direction

Page 55: Ninja Cat Flyer - 1 of 6

1. Scroll down,

then check

“Color over

Lifetime”

2. Click the color box

3. Select

top-right

slider

4. Set value

to 0 (zero)

Page 56: Ninja Cat Flyer - 1 of 6

Drag Mountains

into Scene

Page 57: Ninja Cat Flyer - 1 of 6

Drag Mountains

into SceneSet Transform

Position:

• X = 0

• Y = 0

• Z = 0

Page 58: Ninja Cat Flyer - 1 of 6

Click to

Add Sorting Layer…

Select

Cat in

Hierarchy

Page 59: Ninja Cat Flyer - 1 of 6

Add Layers for

1. Background

2. Decorations

3. Objects

4. PlayerClick + icon

to add each

new layer

Page 60: Ninja Cat Flyer - 1 of 6

Assign Sorting Layer

Select Player

Page 61: Ninja Cat Flyer - 1 of 6

Assign Sorting Layer

Select Background

Page 62: Ninja Cat Flyer - 1 of 6

Right-click Scripts, click Create C# ScriptName it

“ParticleSortingLayerFix”

Page 63: Ninja Cat Flyer - 1 of 6

Drag Script

to jetpackFlames

Verify Script

Component

Page 64: Ninja Cat Flyer - 1 of 6

Double-Click

Script Name

Page 65: Ninja Cat Flyer - 1 of 6

Start() Begins {

} Start() Ends

Page 66: Ninja Cat Flyer - 1 of 6

Run

Page 67: Ninja Cat Flyer - 1 of 6