diff --git a/source/funkin/play/stage/Bopper.hx b/source/funkin/play/stage/Bopper.hx index 3a57072e6..262aff7bc 100644 --- a/source/funkin/play/stage/Bopper.hx +++ b/source/funkin/play/stage/Bopper.hx @@ -167,10 +167,7 @@ class Bopper extends StageProp implements IPlayStateScriptedClass function update_shouldAlternate():Void { - if (hasAnimation('danceLeft')) - { - this.shouldAlternate = true; - } + this.shouldAlternate = hasAnimation('danceLeft'); } /** @@ -228,10 +225,11 @@ class Bopper extends StageProp implements IPlayStateScriptedClass /** * Ensure that a given animation exists before playing it. - * Will gracefully check for name, then name with stripped suffixes, then 'idle', then fail to play. - * @param name + * Will gracefully check for name, then name with stripped suffixes, then fail to play. + * @param name The animation name to attempt to correct. + * @param fallback Instead of failing to play, try to play this animation instead. */ - function correctAnimationName(name:String):String + function correctAnimationName(name:String, ?fallback:String):String { // If the animation exists, we're good. if (hasAnimation(name)) return name; @@ -247,14 +245,22 @@ class Bopper extends StageProp implements IPlayStateScriptedClass } else { - if (name != 'idle') + if (fallback != null) { - FlxG.log.warn('Bopper tried to play animation "$name" that does not exist, fallback to idle...'); - return correctAnimationName('idle'); + if (fallback == name) + { + FlxG.log.error('Bopper tried to play animation "$name" that does not exist! This is bad!'); + return null; + } + else + { + FlxG.log.warn('Bopper tried to play animation "$name" that does not exist, fallback to idle...'); + return correctAnimationName('idle'); + } } else { - FlxG.log.error('Bopper tried to play animation "idle" that does not exist! This is bad!'); + FlxG.log.error('Bopper tried to play animation "$name" that does not exist! This is bad!'); return null; } } diff --git a/source/funkin/ui/story/LevelProp.hx b/source/funkin/ui/story/LevelProp.hx index b126f0243..d8eae9c77 100644 --- a/source/funkin/ui/story/LevelProp.hx +++ b/source/funkin/ui/story/LevelProp.hx @@ -45,6 +45,9 @@ class LevelProp extends Bopper this.visible = true; } + // Reset animation state. + this.shouldAlternate = null; + var isAnimated:Bool = propData.animations.length > 0; if (isAnimated) {