Visual Programming

PLAYMAKER IN UNITY

VISUAL PROGRAMMING

SHOWCASE

COMBAT CORE

"As a designer and artist without strong coding skills, with Playmaker I’m able to bring my ideas to life without any limits."
- Micah Betts

FINAL FOOTBALL SAGA

"Working with Playmaker is like drawing my ideas on paper.
I am a veteran coder but I love to see my code ideas in a snapshot."
Ruben Alcaniz

SHOWCASE

THE FIRST TREE

"I would have never released a game if it wasn’t for Playmaker.
For artists like myself, it opens up a new world."
David Wehle

SHOWCASE

HEARTHSTONE:
HEROES OF WARCRAFT

“That’s something we’ve used in the game to create scripted events alongside our animation system. It was actually a big help in enabling our art team to independently make cool events in-game.”

SHOWCASE

SHOWCASE

ASSET STORE

SHOWCASE

ASSET STORE

FEEDBACK

FIFA CUP JOURNEY

FEEDBACK

TROJKA FLAKES/STARS

FEEDBACK

TROJKA FLAKES/STARS

FEEDBACK

TROJKA FLAKES/STARS

FEEDBACK

TROJKA FLAKES/STARS

Playmaker uses event-driven FSMs to control Unity

1. Start Event

  • A Start Event is sent when the FSM is enabled.
     
  • The start event activates the first state, known as the Start State.

2. State

  • Only one State can be active at a time.
     
  • The Active State executes Actions and receives Events.

3. Transition Event

  • Events trigger transitions to another State.
  • Events can be sent by Unity (collisions, triggers, mouse input, animation events...)
     
  • Or by Actions (distance checks, timeouts, game logic...)

4. Transition

  • The Active State is "exited" and the new state is "entered."
  • The Graph View makes it very easy to build and debug these transitions.

5. Global Transition

  • A Global Transition can be triggered at any time, regardless of the currently active state.
  • In the example above, the character can be hit at any time, so we use a global transition.
     
  • Global transitions can simplify FSMs by reducing the number of explicit transitions you need to define.

ACTIONS

The currently active state executes Actions.
Actions have parameters that can be edited in the Action Editor.

VARIABLES

A variable is a named container for a value. Action parameters accept variables as well as hard-coded values.

 

A variable has several advantages over a hard-coded value:

  • It has a name that makes its value more meaningful (e.g., maxNumberOfLives instead of 99).
  • The same variable can be used in multiple places. Hard-coded values have to be changed separately.
  • A variable's value can change over time!

EVENTS

All transitions between States are triggered by Events.
 

Use the Event Manager to add/edit Events.

There are 2 basic types of Events:

1. System Events: Sent automatically by Unity/Playmaker;
    cannot be edited or deleted.

2. User Events: Custom events that you can use however​ you want.

TEMPLATES

Any FSM can be saved as a Template that can then be re-used.

Templates also let you nest FSMs, so you can build reusable blocks that can be run wherever you need them.

  • Referencing Templates

  • Pasting Templates

  • Exposing Template Controls

UI

  1. Selection Toolbar (FSM selection tools)
  2. Graph View (Edit States and Transitions)
  3. Inspector Panel (Edit the selected FSM/State)
  4. Debug Toolbar (Debug and Play tools)
  5. Preferences (Playmaker settings)

EXAMPLE

EXAMPLE - SET FSM PARAMS

public class Root : MonoBehaviour {

	[Range(1, 20)]
	public int botsAmout; 

	[Range(10, 40)]
	public int bulletsAmout;

	void Start () {
		FsmVariables.GlobalVariables.FindFsmInt ("CONST_BOTS_AMOUNT").Value = botsAmout;
		FsmVariables.GlobalVariables.FindFsmInt ("CONST_BULLETS_AMOUNT").Value = bulletsAmout;
	}
}

Setting Global Variables from C# code with static methods from Playmaker API.

EXAMPLE - ROOT INITIALIZATION

1.

2.

1. Initialization of the game entities (unit, containers, bots).
Loop with events.

2. Setting GUI values.

EXAMPLE - UNIT (Marine)

Move to Click FSM: Waiting for MouseClick and use "Move Toward" action to animate Unit to the position. During the "Move" state we can choose another point (Duplication).

Look at cursor: Simple "Look At" action repeated every frame.

EXAMPLE - UNIT (Marine - Gun)

Marine_Gun - "Fire the bullet" FSM is responsible for:
- creating a bullet
- checking amount of possible shots
- setting the "Bullets: #" GUI text

EXAMPLE - BULLET

1. Bullet has a kinetic "Rigidbody Component" and waiting for collision trigger event, which filtered based on the tag

2. Bullet signalizes to the "hitted" bot's FSM (which is stored in the local variable) about collision by "Send Event" action.

Bot then handling that collision by himself with event: DESTROY_BOT

1

2

EXAMPLE - BOT

Bot moving in the same way as bullet. On that state we are listening for global event - DESTROY_BOT which might come only from bullet.

Bot must have a "Rigidbody Component"

EXAMPLE - SETTING GUI TEXT

To be able to set text to UGUI text field (Unity.version > 4.6) we need special action which is not included by default:

- U Gui Text Set Text.

We can find it with special add-on "Ecosystem Browser"

Before combining "string" with an integer values, these "integers" must be converted to "string" (Convert Int to String).

EXAMPLE - ECOSYSTEM BROWSER

Playmaker
    - Addons
       - Ecosystem
          - Ecosystem Browser

DISCUSSION

Visual Programming in Unity Intro

By Vladimir Cores Minkin

Visual Programming in Unity Intro

  • 1,089