Asset - Objects PRState: A simple and efficient finite state machine.


Available on the YoYo Games Marketplace and on
Requires GameMaker Studio 2 v2.3 and up.

PRState is a GameMaker Studio 2 (GMS) package created by Prismatic Realms, Inc. It enables you to implement a simple and efficient finite state machine for your GMS objects. PRState is designed to compartmentalize your object's state implementation code so that they are segregated from each other and from the rest of your object's code. What this means is that, for example, your hero character's walk/run code lives in its own function or method. The same goes for his attack code, and his double-jump code, etc. This results in code that is more organized and easy to trace and debug, rather than having all that code lumped together into your Step event(s)

Note that PRState can be used for more than just keeping track of character states. Consider using PRState to track the different states of your UI objects (buttons, check boxes, etc.) or to track which magical energy a sword is currently imbued with. There are many uses for finite state machines. Any object with more than one behaviour can benefit from this module.

This package contains an object that implements PRState that your objects can derive from. The package also contains documentation on how to use the module and example code that you can learn from.

The included examples feature artwork by Penusbmic (used with permission.)

  • Add any number of states to your objects.
  • Associate specific methods or functions to your states to handle their implementation.
  • Change the object states at any time.
  • Handy convenience method to switch to previous state.
  • Impose restrictions as to which states can transition to other states, handled automatically by PRState.
  • Organized implementation. Your state methods/functions will be called once to initialize itself when set; once to cleanup after itself when the state is about to be switched away; and once every frame to run your implementation code.
  • Debug logging to help you track when objects change states.
  • All professionally written in GML.
  • Includes examples and documentation within the package.
  • Fast and friendly support via email if and when you need it.
Support Website:



Last edited:
PRState v2.0.1 now available.

Change Log:


  • Code overhaul. Re-written for GameMaker Studio 2.3. All module functions are now implemeted as object method variables.

  • Implemented updated in-house module format and naming conventions. Please read the note PRState_Information for details.
  • A blank state name (or noone) is now considered a "valid state", which represents no state. PRCanSetState() now returns true for blank (or noone) state names.
  • When the object has no state, PRGetCurrentStateInfo function now indicates "NO STATE" rather than a blank string.
  • PRGetCurrentStateInfo function now also includes previous state information.
  • PRAddState function now fails to add state if state name was not provided.
  • PRSetPreviousState() now accepts 3 optional parameters: data1, data2 and data3 which override the previous state's data values if provided.

  • Setting the object's state to "no state" (i.e. a blank state name) was not calling the object's current state in "end" mode. It does now.
  • Was not setting the data1, data2 and data3 properties to noone when they were not specified in the call to PRSetState. Fixed.

  • None
Small bug fix release.
PRState v2.0.2 now available.

Change Log:


  • None


  • None


  • Fixed bug in PRCanSetState() method that incorrectly returned false for states with no "valid from" states defined.


  • None
We have created this tutorial video about our GameMaker Studio 2 finite state machine extension PRState, though it can also be viewed by anyone willing to learn a bit of retro platform game development. Enjoy!

Last edited:
The PRState Support website has been revamped and made up-to-date. Won't you have a visit?

The URL has been added to the first post in this thread for your convenience.