[SOLVED] How to control UI animations from another UI?

To access another objects (widgets in this case) you need to get references to the objects somehow.
Probably the most simple and correct way is to spawn all these widgets from a single manager/controller and so pass the required references or use the manager to pass commands from one widget to another.


So I have an intro animation on two different user interfaces, and a separate “console” all it is, is a text box which allows me to create custom commands, now the console is in a UI and all the code is in there, what I want is when I type in my command, (which again, it’s ready to perform a command, so I only need the next part really) is make it play an animation from a different user interface.

Can anyone help me with this?

I’ve tried simply getting the animation and using a play animation, but for some reason, nothing happens, is there a specific way I need to get the UI and it’s animation in order to play it, stop it, etc?

I understand the question is confusing, but it’s difficult to word it really.

Basically, you have a main menu, and it plays an animation, then I have another UI which also has an animation, but in order to use that other UI, I use the console, so basically, I want to reverse the main menu animation, and then play the other UI animation, so it’s “transitioning” I know my methods are probably bad, but honestly, I’m not going to change it.



EDIT: I should’ve mentioned that I’m new to blueprint, so please provide an example if you can, since I’m still learning them.

Thank you, could you give me an example please, I’m new to blueprint so I’m not entirely sure how to do that.

There are different ways possible, it depends on how do you spawn your widgets. Here is a possible example: HTF do I? Blueprint to Blueprint Communication - YouTube
It’s not exactly about the widgets, but the idea is the same.

I use 2 methods for these types of issues:

  1. when i create the umg i store it to a variable inside game mode and then i cast to the game mode from wherever i want and call the umg variable and do whatever i want.
  2. you could just store your data to a game mode and in the other blueprint you can use event tick to cast to game mode constantly and check to see if said data is stored. (not recommended method)

Could you provide an example please? I’m new to blueprint, so I’m still learning them.

ok i will keep it as simple as possible
first off you need 3 things 1.game mode blueprint 2.umg widget blueprint 3.pawn/character blueprint
now create a custom game mode blueprint and set it in the level with steps below:

  1. World Settings Tab → Game Mode

2.Edit -->Project Settings → Maps & Modes → Default Modes
now create a widget blueprint and pawn/character blueprint.
open up your pawn/character blueprint and add a widget then cast to the game mode and store the created widget inside the game mode.
now in the level you can cast to the game mode and call the widget through game mode as a reference.
i have also uploaded a UE4.21 project with explained things above added to it which i think you will be able to better understand.
hope it helps !

Sorry that I’ve taken so long to reply, but this worked perfectly! It’s exactly what I needed and works well, granted I had to make a few modifications to suite my game, but not many and it works exactly how I need it to! Thanks :slight_smile:

GameMode is not a good place to keep a UI elements. With this approach it’s better to use PlayerController. There is no big difference for a single-player game, but in case of any multiplayer it will make a mess in GameMode or just won’t work properly.

OK, well I followed the tutorial you linked before, and it does still work, but again, how can I control more than one menu? Because for some reason, I tried using the exact same cast method but it’s just not working, and I’m not sure why? The sub menu plays it’s animation and shows no problem, but because the main menu is already present, trying to play it’s animation in reverse using the cast just isn’t working.

thanks for the precious tip, I’ll keep that in mind.

OK, so I sort of figured out what’s happening, so for some reason, when I run my command, it’s almost as if it can’t see that theirs already a main menu widget on the screen, I did a little test to check for the widget and it returned false, so can anyone help me figure out how to solve this? Because, basically when you start the game, the main menu is created, but when I run my command, it’s almost as if it’s not actually there, and can’t control it, since it doesn’t look right to create a widget on top of the same widget.

OK, so after a lot of messing around, I managed to fix it, what I did, was create a function (see image 1), which creates the main menu, since when it was being created by the level blueprint, the command prompt basically didn’t see that it was there, so all the function does, is create a menu, which is then called in the same character blueprint when you press ‘C’ which is the command key, shown in image 2, for some reason it creates a widget but doesn’t add it to the viewport, so I’m assuming that makes it so the command UI knows it’s there. And then just play the animation command seen in image 3.

This probably isn’t very efficient, but it does work and that’s mainly the important thing, the best part is the main menu still functions like it should!

Thanks everyone for your suggestions as they helped me get to this point. :slight_smile:

Image 1:

Image 2:

Image 3.1:

Image 3.2:

From your screenshots, I don’t see where are you calling the “Add Menu” function. Also it’s better to create the menu right from the player controller, since menu is for a specific player, not for the whole level (again, it make difference only in case of multiplayer, but still it’s better to organize everything from the start – it will help if the project will become larger).

Currently I see that you’re creating a new widget each time when pressed C button and this widget is not shown on the screen at all.

The way how are you making the Dev Menu widget looks more valid - you’re making it just once on begin play and keep the reference for future access.

Basically, the function is created in the player controller, and called on the level blueprint for the main menu, it’s quite literally a play, quit and credits button, nothing complex at all, and yes, that’s the point, when I press C it’s creating a reference to control the animations, and the other Dev menu is created when I type the appropriate command. It’s a simple system I know, but I’ve got the desired effect and menus that I wanted, it’s a simple single player game that will be free, so I’m not that fussed how certain things work, providing, as I said, the menus play their animations and work.

Thank you.