Blueprint Interface and playing Widget animations

I’m trying to create a simple presentation, that should be easily accessible to anyone who comes across it regardless of their IT literacy skill level.
I have several objects spaced out with 3D widgets stating their names/properties. These objects are clickable and UE plays a quick camera animation to zoom to the object when clicked.
I also have some menu widgets for navigation which don’t directly relate to any of the clickable objects. These widgets are animated to add and remove them from the screen during navigation.

What I’m trying to do is play the navigation animation to remove the menu from the screen when an object is clicked and the camera animation is played.
Removing from parent, removes the wrong widget, and removing all widgets also removes the 3D ones which I don’t want.

I’ve been looking around at Blueprint Interface tutorials, but there’s nothing quite like this that I’ve seen and I’m having difficulty understanding how to use them - even following tutorials step by step I get different results (i.e. can’t get an ‘Event’ option for the Interface after adding it to the class settings, only a ‘function’ option)
BPI_OnClicked BPI_Function_Implemented

BPI_Function

BPI_Animation_Implemented

Hey again @PX54!

So what it looks like from what I can see is that the Target on New Function 0 is set to be “touched Component”, but it needs to be the widget. I’d need more screenshots to be absolutely sure.

Try putting a printstring between the click event and the outgoing BPI message, and plug your “Touched Component” into the printstring. Then test it. If it says it is indeed bringing the widget as the target, then that’s not it. But I’m betting it’ll say “Cube” or whatever your collision box is named. :slight_smile:

Give that a shot and get back to us!

Yes, it gives ‘Cube’.
Clickable_Mesh_String

So how to I set the target to the widget? I can’t find it when I search, and I’ve tried ‘self’ also.
Edit:
Scratch that I think I figured that bit out.
ClickableMesh_Variables
I’ve created a variable called Animated Widget, and set it’s type to the Animated Widget Blueprint
ClickableMesh_Variables_Set

Then I’ve set that as the target for the BPI message

But this still doesn’t do anything.

Try throwing a printstring after the “Event Play Widget Animation” And before Play animation, to check if the interface is working correctly.

Also make sure “Button Click” variable is set!

I know the Play Animation and Button Click work, because of the other 4 ‘on clicked’ events attached to it all work as intended.

It’s the BPI Event that doesn’t appear to be firing. Putting a Print String in didn’t show anything.

Everything after the BPI Message also runs (play level sequence), so it’s not like the ‘On Clicked (Cube)’ get’s stuck and stops processing, it just doesn’t appear to fire/respond.

Is what I’ve done with the variable BPW Animated Widget the correct way to reference the widget as the target?

How did you set the value of that variable. Do a isValid check; it’s probably null. Creating a reference variable does little unless you point it at a valid object. What if you had 3 animated widgets and 3 variables? Which one is which?

Imagine creating a string variable but forgetting to type in the text. You have a variable that could hold text but does not yet.

I created the Variable in the Blueprint and then set it’s type to the specific Widget I wanted to reference.
(I’ve changed the variable name in the image below to differentiate)

I’ve just run the isValid check and it does indeed return false.

That will not work. You’re messaging nothing with the interface.

This is the bit that is not working, right?

Where is that BPW Animated Widget? Where, how and when is it created? In which blueprint?

Sorry, I’d called them both the same thing originally - do you mean the variable or the widget?

The Variable (that I renamed for the previous post) is created in the Blueprint with the ‘OnClicked (cube)’ event. I then set the type of the variable to the Widget Blueprint that I want the BP Interface to send the message to.

The Widget Blueprint (also called BPW Animated Widget) is a separate Blueprint.

So what is it that I need to put in the target to get the BP Interface to work, and play the animation sequence in the Widget?

I meant the actual widget.

The Widget Blueprint (also called BPW Animated Widget) is a separate Blueprint.

So how does this separate Blueprint come to life? Is it spawned, created as a regular widget with script, is it a widget component attached to the actor, is it a part of some other actor that is in the level blueprint perhaps?

So what is it that I need to put in the target to get the BP Interface to work, and play the animation sequence in the Widget?

The target will the instance of the widget. How to get there will be easier if you know where it is - hence the questions above.

oh ok sorry.

It’s set to spawn on BeginPlay from the Level Blueprint

And the cubes you click are also in the scene? Placed manually?

Yes, they are

To create a reference, you can promote a pin by right clicking it:

Once you have a reference, you can play the animation:

Yes, they are

Brilliant, if it all happens in the LB and if I wanted to play a widget animation by clicking on some actors:

  • drag the actors to the LB to create references:

  • in the widget:

image

You can create this event like so:

And then cut & paste it to the widget.


If you have 4000 cubes rather than 4, do tell. No one can drag 4 thousand wires around. Or if you have some rules regarding which cubes play which animation, it can also be automated.

And if you have 1 particular mesh that is clickable:

1 Like

Sorry, I’ve probably not fully understood you.

So there’s 13 (I think) cubes that will be required in the end.

The animation they’re playing is to move buttons on and off the screen in the widget.

I don’t want the animation to happen automatically, it needs to happen when the cube is clicked by the user, to change menus within the widget.

It doesn’t all happen in the level blueprint (unless you were saying it needs to), only the spawning of the widget.
The interface message is in the cube blueprint because it needs to happen on click, which also plays a camera sequence.

The above script would work exactly like you’ve described. It would play an anim when the cube is clicked. If you have 13 and that’s too many to connect by hand:

Perfect, it does work. Can’t thank you enough.

Only thing, when I stop the editor I now get a warning.
Editor_Error_1

It means we’re Adding to the Viewport more than once. It may cause a memory leak, depends on what’s underneath. Can you show how the widget is created and added? On Begin Play? Perhaps it’s in the loop?

I do have 2 ‘add to viewports’ but it was like this before and not giving the error. Do I not need both?
Edit:
Removing one didn’t change anything - still works and still gets the warning.

Nah, I think you’ve accidently connected 2 wires to Add to Viewport:

image

Here:

image

Most likely! Wiggle that Add To Viewport node to find out.