Forum rules - please read before posting.

Trigger change for UI sprite

Hi!
In my current game, my characters have cartoony speech bubbles for their subtitles.
i'd love to swap the sprite of their speech bubble so if a character is yelling, the speech bubble can look all spikey or something.
I've tried writing a custom action (following the tutorial on adventurecreator.org) using the uiImage.overrideSprite command and triggering it in the actionlist editor but i couldn't get it to work.

I also tried making an animation for the subtitleUI that swaps the sprite. However, i couldn't find a way to trigger that animation in the actionlist editor.

I'm not much of a programmer, and I'm sure this is easier than i realise. I just can't do it.

Comments

  • Using animation would be the easiest way - if you use Trigger parameters to run each animation, you can test the behaviour by invoking them manually in the Animator window at runtime.

    You can use the "Object: Animate" Action to invoke them in Actions - just make sure that the Action generates and records a Constant ID component for the Animator object that's in the UI canvas prefab, though this should be automatic.

    Share screenshots if you need another set of eyes on your approach.

  • Thanks Chris!

    I think i'm about halfway there. Is this the correct action set up?

    I've set up a trigger parameter in the animator for the subtitleUI and i've also placed the animation i want to trigger in there. I'm just not sure how to use them or how to connect them.

  • Once you've created a transition in the Animator (that uses the Trigger parameter as a condition) to play the animation, you can type that parameter's name into the Action's "Parameter to affect" field to invoke it.

    If the Subtitles UI is a prefab that's spawned in at runtime, though, you'll need to have the Action affect the runtime instance of it - and not the asset file. Are you using a scene-based Action? Drag the prefab file into the "Animator" field from the Asset window - don't drop it into the scene first. That way, it should register a Constant ID value for it.

  • Thank you. I've got it working.
    Although, sometimes the animation takes a second to load and the old speech bubble is visible for a fraction of a second. I'll fiddle around and see if i cant fix it.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.