Unity 2D: Step by Step, Part 4

Slides:



Advertisements
Similar presentations
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Advertisements

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Feature: Reprint Outstanding Transactions Report © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
Derived from Kirill Muzykov’s Rocket Mouse Tutorial WakeUpAndCode.com.
Feature: Purchase Requisitions - Requester © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Feature: Payroll and HR Enhancements © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Co- location Mass Market Managed Hosting ISV Hosting.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Windows 7 Training Microsoft Confidential. Windows ® 7 Compatibility Version Checking.
Feature: Purchase Order Prepayments II © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Feature: OLE Notes Migration Utility
Feature: Web Client Keyboard Shortcuts © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Session 1.
Built by Developers for Developers…. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
 Rico Mariani Architect Microsoft Corporation.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Assign an Item to Multiple Sites © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Derived from Kirill Muzykov’s Rocket Mouse Tutorial WakeUpAndCode.com.
WinHEC /22/2017 © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Print Remaining Documents © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Connect with life Connect with life
NEXT: Overview – Sharing skills & code.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Suggested Item Enhancements – Sales Script and Additional Information © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows.
Feature: Customer Combiner and Modifier © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
demo Instance AInstance B Read “7” Write “8”

customer.
Derived from Kirill Muzykov’s Rocket Mouse Tutorial WakeUpAndCode.com.
demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Derived from Kirill Muzykov’s Rocket Mouse Tutorial WakeUpAndCode.com.
demo Demo.
Feature: Void Historical/Open Transaction Updates © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
Feature: Suggested Item Enhancements – Analysis and Assignment © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and.
projekt202 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
The CLR CoreCLRCoreCLR © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.

Возможности Excel 2010, о которых следует знать
Unity 2D: Step by Step, Part 2
Title of Presentation 11/22/2018 3:34 PM
Office Mac /30/2018 © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Title of Presentation 12/2/2018 3:48 PM
Brian Keller Sr. Technical Evangelist Microsoft Session Code: DEV310
Brian Keller Sr. Technical Evangelist Microsoft Session Code: DEV310
Tech for Startups By Shahed Chowdhuri Sr. Technical Evangelist
Game Development with Unity and C#
Intro to Construct 2 Game Development
Azure Mobile Services in the Cloud
Capturing Your Audience with Kinect
Deploy Your Web Site/App on Azure
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
PENSACOLA ENERGY WORK PLAN OCTOBER 10, 2016
Title of Presentation 5/12/ :53 PM
Шитманов Дархан Қаражанұлы Тарих пәнінің
Title of Presentation 5/24/2019 1:26 PM
5/24/2019 6:44 PM 1/8/18 Bell #10 In a world governed by the gods, is there any room for human will? Do human choices make a difference? EXPLAIN © 2007.
日本初公開!? Vista の新機能を実演 とっちゃん わんくま同盟 7/23/2019 9:09 AM
Title of Presentation 7/24/2019 8:53 PM
Construct 2 Game Development: Flapping Bird
Presentation transcript:

Unity 2D: Step by Step, Part 4 6/1/2018 Unity 2D: Step by Step, Part 4 Derived from Kirill Muzykov’s Rocket Mouse Tutorial http://www.raywenderlich.com/69392/make-game-like-jetpack-joyride-unity-2d-part-1 By Shahed Chowdhuri Sr. Technical Evangelist Title Page: Unity 2D: Step by Step Based on Kirill Muzykov’s Rocket Mouse Tutorial http://www.raywenderlich.com/69392/make-game-like-jetpack-joyride-unity-2d-part-1 By Shahed Chowdhuri Senior Technical Evangelist Blog: WakeUpAndCode.com Twitter: @shahedC WakeUpAndCode.com @shahedC © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Adding Lasers Moving the Mouse

Add Laser to Scene Drag “laser_on” from “Sprites” subfolder into Scene

Rename the Laser Rename “laser_on” to just “laser”

Update the Laser’s Sorting Layer Set the laser’s Sorting Layer to “Objects”

Add a Box Collider 2D Component Verify “Box Collider 2D” For the laser object, click Add Component  “Physics 2D” Click “Box Collider 2D”

Enable “Is Trigger” and Update Size Enable “Is Trigger” Checkbox (This allows you to handle collisions in your code instead of the Physics engine) Update Size: X = 0.18 Y = 3.1

Add a Script named “LaserScript” For the laser object, click Add Component  “New Script” Enter “LaserScript”, click “Create and Add” Verify new script

Update “LaserScript” Code Add these 6 instance variables inside LaserScript Add 1 line in Start() method

Add FixedUpdate() Method method just before the class ends

Drag Laser On/Off Into Script Properties With “laser” selected, drag on/off sprites into script properties

Update Laser Properties Position: X = 2 Y = 0.25 Z = 0 Laser Script Rotation Speed = 30

Create a Laser Prefab Drag “laser” from Hierarchy to Prefabs folder

You should see a rotating laser! Run the Game! Run You should see a rotating laser!

Handling Dying & Falling Moving the Mouse

Launch “CatController” Script

Add New Instance Variable

Add New Methods Add 2 new methods just before Start()

Revise FixedUpdate() Method Reassign jetPackActive boolean Check if (!dead) i.e. not dead

Select Animations Folder in Project All your animation clips will be created here

Create New Animation for Dying In the Animation tab, with Cat selected in Hierarchy… Create New Clip, “die” under Animations subfolder

Verify New Animation Verify “die” animation in Animations subfolder

Drag In Animation Frames Ctrl-Select “die0” and “die1”, then drag animation frames into Animation window

Update Sample Value Change Sample Value to 8 for “die” animation

Stop Recording Click “Record” button to stop recording

Create New Animation for Falling In the Animation tab, with Cat selected in Hierarchy… Create New Clip, “fall” under Animations subfolder

Verify New Animation Verify “fall” animation in Animations subfolder

Drag In Animation Frame Select “fall”, then drag animation frame (just one) into Animation window

Stop Recording Again Click “Record” button to stop recording

Creating Transitions Moving the Mouse

Create New Bool Parameter In the Animator tab Click the + next to Parameters, Then add a new Bool

Name the Parameter Name the new parameter “dead”

Make a Transition from Any State Right-click “Any State”, then click “Make Transition”

Complete Transition to Fall Click the “fall” state to complete the transition from “Any State” to “Fall”

Create Condition Click the new Transition in the Animator tab, Then, select “dead” under Conditions in Inspector

Set Condition for “dead” Set “dead” to true, then… Click + to “Add to list”

Create Another Condition Select “grounded” for the new condition… Set “grounded “ to false NOTE: For this transition, “dead” is true, but “grounded” is false

Make Another Transition from Any State Right-click “Any State”, then click “Make Transition”

Complete Transition to Die Click the “die” state to complete the transition from “Any State” to “Die”

Create Condition Click the new Transition in the Animator tab, Then, select “dead” under Conditions in Inspector

Set Condition for “dead” Set “dead” to true, then… Click + to “Add to list”

Create Another Condition Select “grounded” for the new condition… Set “grounded “ to true NOTE: For this transition, BOTH conditions are true! (“dead” AND “grounded”)

Launch “CatController” Script

Update HitByLaser() Method Add 1 line of code inside HitByLaser() NOTE: This ensures that “dead” condition is set to true when HitByLaser() is called

Handling Triggers Moving the Mouse

Create New Trigger In the Animator tab Click the + next to Parameters, Then add a new Trigger

Name the Trigger Parameter Name the new Trigger parameter “dieOnceTrigger”

Disable Dying Loop Select the “die” animation in the Project panel Uncheck Loop Time

What happens when the cat touches the laser? Run the Game! Run What happens when the cat touches the laser?

End of Part 4 Contact Web: OnekSoft.com Email: games@OnekSoft.com Twitter: @OnekSoftGames Microsoft email: shchowd@microsoft.com Personal Twitter: @shahedC R&D: OnekSoftLabs.com Dev Blog: WakeUpAndCode.com