• Nothing
  • About
Menu

Asher Einhorn

  • Nothing
  • About
notify.png

State machine messages

June 22, 2015

Imagine you have a situation we often encounter in a game - a character approaches a ladder and begins to climb it.

What is really happening behind the scenes to make this happen? First we would position the character under the ladder, where a trigger-box may alert the code that we can now press a button to enter a ladder climbing state.

When we press this button, the character places their hands and legs on the ladder - an authored animation that takes a few seconds to play out. Now we need to switch to a different movement scheme so the character can move up and down the ladder. But how do we make sure we're switching to this state at the right time so that we don't try and start moving the character before they've finished playing this animation?

The answer is to catch a message sent from the animation state machine. This is a feature almost all commercial engines now offer. You can set up specific transitions or states to send a message when they have been entered or left, and you can then use these messages to trigger code at exactly the right time. You can also often set up specific markers in an animation to send out a custom message at a specified time.

This two-way communication is a key tool that we use in scripting complex gameplay, as we will see in upcoming blog posts.

In Scripting Handbook Tags Animation, Tutorial
← How would we script... The grenade-shooting moment from MGS5Root-motion →
Twitter
  • RT @CKapmeh: Sunday Capilla San Bernardo / Nicolás Campodonico https://t.co/V56q7uftPf
    May 28, 2017, 10:42 AM
  • Crunch dadaism. Come to @Naughty_Dog and experience the highs of creative culture. https://t.co/9yMPcTdiYA
    May 27, 2017, 9:33 AM
  • Crunch garden #gamedev Avocado, Lemon and Peppers. From right to left. https://t.co/jtZXeWDEgh
    May 27, 2017, 9:31 AM
  • Working with a migraine two days in a row is quite possibly the most unpleasant thing in recent memory.
    May 26, 2017, 3:36 PM
  • Sure is fun to have a night off! #PS4share https://t.co/WMcEMY5yWE
    May 21, 2017, 7:59 PM
  • The EU/US PSN account conflict is an ongoing nightmare. Looks like I'm not playing anything tonight after all.... pain!
    May 21, 2017, 7:49 PM