Share
Embed
Transcript
24 slides
-
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 -
Getting Started • Import from Unity Asset Store • Tip:
Uncheck “Photon Unity Networking” for Free Unity and Android -
Enabling Playmaker • PlayMaker menu should appear in Unity •
Select Playmaker Editor • Empty Playmaker pane should display -
Editor Pane • FSM State Diagram – Dropdown of GameObjects
with FSMs • FSM – Can change FSM name • State – Actions for current state • Events • Variables • Preferences -
Action Browser • Contains standard Unity methods and more •
“Code” is written by adding actions to states -
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 -
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” -
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 -
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 -
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 -
Follow Camera • Add FSM to Camera • Transform >
Smooth Follow Action • Set Target to player • Set Damping values to modify camera follow lag -
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 -
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 -
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 -
Managing Actions • Actions can be easily disabled by unchecking
them • Actions can be copied and pasted into other FSMs -
First Person View • Disable Smooth Follow Action • In
a new FSM, use Set Parent action • Set the Camera’s Parent to player -
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 -
Icon Display • Use the “Gizmos” dropdown menu to resize
or disable icon display -
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 -
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 -
Fade In / Out • Create FSM on camera •
Add action • Set Color and Time • Can send event when completed – Reload level, game over screen, etc -
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 -
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