Event Metronome Script
Overview
A custom script is needed to keep various audio and visual elements of the game in sync due to the game having an “Act to the beat of the music” Mechanic.
A Metronome is needed that sends out an event at the set BPM that Playmaker state machines can react from = An Event Metronome.
Can’t this just be done in playmaker?
This can’t be done in Playmaker because the time scale of playmaker and the time scale of the music track seems to venture off sync. It doesn’t look like 1 playmaker second = 1 second of audio playing.
My speculation as to why this is: State machines have 1000’s of seconds delays in moving from one state to the next that adds up over time: creating desync.
So a custom script is needed to keep all the playmaker scripts in sync to a BPM.
How it should work:
The script should activate upon the associated track playing and then run until the end of the scene / level.
This script should send out an “Event” at the rate of the beats per minute defined in this script.
The sent out event is compatible with playmakers FSM system. It should send that event to an FSM location set by the designer in this script.
Exposed inputs the designer can set on the script:
These should be set via the object inspector that the script is attached to:
Audio File Location in object Hierarchy = The script activates its BPM metronome when the audio file starts to play.
Float Variable = Initial BPM time delay = How much (if any) of a delay in seconds there is before the BPM starts to count once the audio track plays. Default = 0
Examples: 2 = 2 second delay. 0.25 = 1/4 second delay
Int Variable = BPM = The beats per minute that the metronome runs from. Default = 120
FSM Location in object Hierarchy = The asset location that holds the (Playmaker) Fixed State Machine.
FSM Event Name = The name of the event the script triggers to “Send” at every beat to the FSM location
What success looks like:
The BPM of the script and of the BPM of the music track stay the same.
Ensuring that Animations and gameplay aspects of the game are kept to the beat.
The default BPM for the dungeon soundtrack is 120.
Multiple event metronome scripts could be used by the designer to handle different BPMs or the same BPM with different initial time delays.
It successfully triggers off Events in Playmaker State Machines.
Order of operations flow: