MouseDance MouseDance
MouseDance MouseDance
MouseDance User Docs powered by DocFx, DiscordFx

Search Results for

    Countdown Animation

    If you want a countdown animation to run at the correct moment, such that it finishes right before the first Hit Object appears, implement ISongStartCountdown in your class like this:

    public class BasicUsage : UnityEngine.MonoBehaviour, MouseDance.Runtime.Callbacks.ISongStartCountdown
    {
      public MouseDance.Runtime.BeatmapRunner _beatmapRunner;
      public UnityEngine.TextAsset _osuFile;
      public UnityEngine.AudioClip _song;
      public UnityEngine.Animator _countdownAnimator;
      public UnityEngine.AnimationClip _countdownAnimationClip;
    
      public void OnStartCountdown()
      {
        _countdownAnimator.Play("Play", -1, 0);
      }
    
      public float CountdownLength => _countdownAnimationClip.length;
    
      void Start()
      {
        _beatmapRunner.SetSongStartCountdown(this);
        _beatmapRunner.LoadAndStart(_osuFile, _song);
      }
    }
    
    Tip

    You will need to have your own countdown animation prepared beforehand. The Demo folder in MouseDance provides a simple countdown animation that you can use.

    Note that BeatmapRunner.SetSongStartCountdown is called before starting the beatmap. This will make your OnStartCountdown be called automatically by the BeatmapRunner at the right moment.

    You can put any code in there that you want. It could be an animation, a sound, etc.

    BeatmapRunner needs to know how long your countdown is (in seconds) so that is what the CountdownLength property is for. The reason is because it will take the absolute time for when the first Hit Object will appear, then deduct the CountdownLength from that. That’s the moment when the BeatmapRunner will call your OnStartCountdown.

    Meaning, if you specify 0 for CountdownLength, then OnStartCountdown will be called exactly when the first Hit Object starts to appear. If you specify 2.5f for CountdownLength, then OnStartCountdown will be called 2.5 seconds before the first Hit Object appears.

    Note that the .osu file can optionally specify a three-second period of silence added before the song plays, with the Lead-in property, so that will be taken into account.

    If in case your countdown animation takes too long and will not fit within the time allotted (even with Lead-in turned on), then MouseDance will automatically add the needed duration of silence.

    Warning

    If your OnStartCountdown doesn't seem to be getting called, check if you've properly called BeatmapRunner.SetSongStartCountdown. For every BeatmapRunner, there can be at most only one active ISongStartCountdown in use.

    BeatmapRunner in the Inspector will show you which callbacks have been registered. The one labeled ISongStartCountdown should be green once the game is running.

    The name of the registered callback's concrete type will be displayed (namespace and class name). If it is a MonoBehaviour type, it'll show the actual file instead. You can click on that to ping it in the Project tab.

    Beatmap Runner Diagnostics

    This GUI is only for debugging. It is not designed or intended to register callbacks from the GUI.