-
-
Notifications
You must be signed in to change notification settings - Fork 290
Description
Problem: Perhaps you want to show that a character is nervous during a conversation, so you add a "shake_x" animation to the portrait. Later on in the conversation, you say something that calms the character down, and you want them to stop shaking. Without editing scripts, this is impossible, as you would need to gauge exactly how many times the animation should repeat before the player reaches the "calm down" section of the timeline. (Assuming it's not locked behind making a specific dialogue choice)
Proposed Solution: If "repeat" is equal to 0 (or add an 'infinite' boolean), the animation will continue to repeat until a new character update event is called for the currently animating character with a new boolean "end animation" checked.
Alternative Solution: For now, I've made a quick workaround for myself and others who may be interested in this functionality. Code screenshots are below.
- Start the animation with repeat 10000000000000000.0.
- To cancel the animation, emit a Dialogic signal with argument "cancel_animation".
- Connect a script to the Dialogic signal event and call Dialogic.Portraits.cancel_character_animation().
- Inside the subsystem_portraits script, cancel_character_animation() loops through the joined characters to find the active animation, calls a new "stop" function, cleans up the node, and removes the animation reference from the character node.
- Inside the DialogicAnimation class, there is now a reference to the active tween, and a stop function that kills the tween if one is active and valid, then emits the finished signal.
- Inside a tween-based animation script (e.g. the shake_x script), create the active tween variable and make the original tween a copy of it, along with setting active tween to null after emitting the finished_once signal.
And badda bing, badda boom, you can cancel the animation whenever you want. It's far from robust, requires you to edit several Dialogic scripts, and it can't currently be used to cancel one of multiple ongoing animations, but it works well enough for what I need. If you wanted to cancel one of multiple animations, you'd have to pass the character's name in the signal event and compare names inside the for loop in cancel_character_animation() before calling stop(). Anyway, here are the screenshots:
