Slide 1

Slide 1 text

Playmaker for Unity Levi D. Smith @GaTechGrad levidsmith.com December 2014

Slide 2

Slide 2 text

Background • Cost: $95 – Often discounted 50% in Unity Asset Store • Requires Unity 3.5 or higher • Created by Hutong Games (@HutongGames) – Alex Chouls and Erin Ko •玩 – Verb: to play, to toy

Slide 3

Slide 3 text

Getting Started • Import from Unity Asset Store • Tip: Uncheck “Photon Unity Networking” for Free Unity and Android

Slide 4

Slide 4 text

Enabling Playmaker • PlayMaker menu should appear in Unity • Select Playmaker Editor • Empty Playmaker pane should display

Slide 5

Slide 5 text

Editor Pane • FSM State Diagram – Dropdown of GameObjects with FSMs • FSM – Can change FSM name • State – Actions for current state • Events • Variables • Preferences

Slide 6

Slide 6 text

Action Browser • Contains standard Unity methods and more • “Code” is written by adding actions to states

Slide 7

Slide 7 text

Actions • Many actions have “Every Frame” option – Similar to Update method or while loop • Can transition to another event with “Send Event” action – Recommended to supply Delay value or FSM may get stuck in an infinite loop • Use “Find Game Object” to access a static GameObject from a Prefab using a tag

Slide 8

Slide 8 text

Creating an FSM • FSM – Finite State Machine – A GameObject can have zero to many FSMs – FSM contains States, Events, Transitions and Variables • Create New – Select game object in Hierarchy tab – Right click PlayMaker pane – Select “Add FSM”

Slide 9

Slide 9 text

States • Examples – Light Bulb • Off and On – Game Character • Standing, Walking, Running, Jumping • For a given FSM, only one state can be active at any given time • A state contains a collection of actions, executed from top to bottom

Slide 10

Slide 10 text

Making a Light Bulb • Create FSM • Add Off and On states • Add MOUSE DOWN events and transitions • Add a point light as a child • Add Activate Game Object actions

Slide 11

Slide 11 text

Moving a block • Add cube GameObject • Add a RigidBody • Add a PlayMaker FSM • Add Moving State • Input > Get Axis – Assign to X and Z variables • Transform > Translate – Assign variables to transform • Tip: Order of actions is important • Tip: Click double line button to enter static values

Slide 12

Slide 12 text

Follow Camera • Add FSM to Camera • Transform > Smooth Follow Action • Set Target to player • Set Damping values to modify camera follow lag

Slide 13

Slide 13 text

Character Tips • Use a capsule collider • Freeze X and Z rotation on RigidBody – Otherwise player will “fall over” • Default terrain map range 0 to 600 – Default height 0 – Impossible to go lower than 0

Slide 14

Slide 14 text

More on States, Events, and Variables • Active state is highlighted in green • Tip: Alt + Click state to manually transition to state • Events can not be called from another FSM unless it is marked Global • Variables are local to an FSM unless defined as a Global variable

Slide 15

Slide 15 text

Jumping • Change default state to “Idle” • Add “Jumping” state • Add “jump” event • Add Input > Get Button Down action – Send jump event • Transition to Jumping on jump event • Add Force action • Transition to Idle on FINISHED event

Slide 16

Slide 16 text

Managing Actions • Actions can be easily disabled by unchecking them • Actions can be copied and pasted into other FSMs

Slide 17

Slide 17 text

First Person View • Disable Smooth Follow Action • In a new FSM, use Set Parent action • Set the Camera’s Parent to player

Slide 18

Slide 18 text

First Person Controls • Add Mouse Look action to enable First Person mouse controls – Action must be on the player object, not the camera! • Uses airplane joystick view control by default • Set Sensitivity Y to negative value to enable traditional first person shooter controls

Slide 19

Slide 19 text

Icon Display • Use the “Gizmos” dropdown menu to resize or disable icon display

Slide 20

Slide 20 text

Operators • Number comparison – Int Compare, Float Compare – Sends events based on less than, greater than, or equal to • Boolean comparison – Bool Test – Sends events for true or false

Slide 21

Slide 21 text

Prefabs • Use Create Object action to Initialize an instance of a Prefab object • Use Destroy Self or Destroy Object to remove a Prefab object and free its resources

Slide 22

Slide 22 text

Fade In / Out • Create FSM on camera • Add action • Set Color and Time • Can send event when completed – Reload level, game over screen, etc

Slide 23

Slide 23 text

Audio • Play Sound – plays the sound component associated with the Game Object • Audio Play – can specify any sound as One Shot Clip • Other actions to mute, pause, stop, play random, set pitch, set volume

Slide 24

Slide 24 text

Getting Help • Playmaker Forums http://hutonggames.com/playmakerforum/index.php • Playmaker Tutorial Videos http://www.hutonggames.com/tutorials_game_design_with_playmaker.php • Playmaker Documentation https://hutonggames.fogbugz.com/default.asp?W1