I need to call Fade-In-Out effect(UI objects also have to disappear and then appear) every time I click on door and teleport. So I need some solution, because everything I found doesn’t work. I know how to create widget and needed animation in BP system, but I don’t know how to call this animation in code, when I need it.
For hidding a UI with fades you don’t need to use code necessarily.
Open your Widget Blueprint where you have the UI and create a new animation called “Fade Out”.
There (I recommend you to have a Canvas Pannel for to contain all the elements in your UI) Track the Canvas Pannel (if not: every element in the UI)
And from the Canvas Pannel track the Render Opacity
Animate from 1 to 0
After that with blueprints from your level, or from the same Widget you can activate or deactivate the animation as you like.
For making a “Fade In” you can make another animation as before, or, I have seen that many users prefer to use the same animation but play it in reverse.
I leave you the Widget documentation for more info about Widgets:
Yeah, thank you, but I need the same animation for full black Image object in UI, because I also need to hide scene, not only UI. And also the question is how to call this animation for THIS black image in code.
Create a (sub) widget that contains the full black image. Make that widget part of your main GUI. Set the default opacity of this widget to 0, and make it not-hit-testable. Make it overlap everything else.
In your PlayerController, after you add the GUI to the player viewport, save a reference to your GUI top-level widget.
When you need to fade-black, call some method on the GUI widget, and have that method (which you implement in your GUI top-level widget) start the timeline to fade in to black.
When you need to fade back, call some other method on your GUI widget, which plays the timeline back again.
The main trick is to make sure that you create and add the GUI widget to the player viewport in your local playercontroller BeginPlay() (or similar hook,) and save the created widget object in a variable, so you have a reference to it in the player controller.
Level Sequences also have a “Fade” track that will fade everything, and if you don’t set up Camera Cuts, it should just do whatever you tell it to do (like fade to black, or back from black).
Oh, sure, the same as Eight_Bit_Punk says, but put the black image in the same UI widget and in front of everything. Then, so it doesn’t bother you in the editor, hide it with the eye icon.