User avatar
Tonas1997
Topic Author
Posts: 1
Joined: 01 Aug 2024, 14:15

Trigger conditions

01 Aug 2024, 16:42

Hello!

I'm trying to implement a "drain" animation on a health bar, which requires a separate ProgressBar that is rendered one layer below the actual health bar. For brevity's sake, I'll be refering to these as the main and drain bars. The expected behavior is as follows:
  • When health is drained, the main bar is immediately updated to the new value, but the drain bar doesn't have its value updated and instead fades out.
  • When the fade-out Storyboard completes, the invisible drain bar can now have its value updated to the new value.
  • Afterwards, the drain bar keeps getting updated to the health value.
Here are the Interaction Triggers I'm using on the drain bar:
<b:Interaction.Triggers>
                    <!-- This triggers the health bar vanishing animation when the player's
                    health is being drained  -->
                    <b:DataTrigger Binding="{Binding LocalPlayerCard.Health.IsDraining}" Value="True">
                        <b:ControlStoryboardAction Storyboard="{StaticResource HealthBarDrainHideAnimation}"/>
                    </b:DataTrigger>

                    <b:StoryboardCompletedTrigger Storyboard="{StaticResource HealthBarDrainHideAnimation}">
                        <b:ControlStoryboardAction Storyboard="{StaticResource HealthBarDrainAnimation}"/>
                    </b:StoryboardCompletedTrigger>

                </b:Interaction.Triggers>
The problem here is that the drain bar value update can only happen when two conditions are met, as neither is sufficient on its own:
  • The health value has changed, requiring a PropertyChangedTrigger.
  • The HealthBarDrainHideAnimation has finished playing, requiring a StoryboardCompletedTrigger (assuming it doesn't run just once).
Since we can't exactly nest triggers, it seems the only way to run a Storyboard after two conditions are met is to either create a custom C++ event or keep track of the elapsed time since the last drain (e.g. if the fade-out animation takes one second, update the value if more than one second has passed after health was lost). I'm not a Noesis expert, so I thought about posting here to make sure I'm not missing more obvious solutions!
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: Trigger conditions

05 Aug 2024, 18:08

I'm not following exactly which conditions and what actions you need to execute, but there is a way to extend a trigger with more conditions, using the ConditionBehavior. Is this what you're looking for?

Who is online

Users browsing this forum: No registered users and 3 guests