Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Playmaker for Unity

LD Smith
December 14, 2014

Playmaker for Unity

Presentation for Knoxville Game Design

LD Smith

December 14, 2014
Tweet

More Decks by LD Smith

Other Decks in Programming

Transcript

  1. 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
  2. Getting Started • Import from Unity Asset Store • Tip:

    Uncheck “Photon Unity Networking” for Free Unity and Android
  3. Enabling Playmaker • PlayMaker menu should appear in Unity •

    Select Playmaker Editor • Empty Playmaker pane should display
  4. Editor Pane • FSM State Diagram – Dropdown of GameObjects

    with FSMs • FSM – Can change FSM name • State – Actions for current state • Events • Variables • Preferences
  5. Action Browser • Contains standard Unity methods and more •

    “Code” is written by adding actions to states
  6. 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
  7. 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”
  8. 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
  9. 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
  10. 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
  11. Follow Camera • Add FSM to Camera • Transform >

    Smooth Follow Action • Set Target to player • Set Damping values to modify camera follow lag
  12. 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
  13. 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
  14. 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
  15. Managing Actions • Actions can be easily disabled by unchecking

    them • Actions can be copied and pasted into other FSMs
  16. First Person View • Disable Smooth Follow Action • In

    a new FSM, use Set Parent action • Set the Camera’s Parent to player
  17. 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
  18. 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
  19. 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
  20. Fade In / Out • Create FSM on camera •

    Add action • Set Color and Time • Can send event when completed – Reload level, game over screen, etc
  21. 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
  22. 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