I want to use on button clicked to activate a function.

I have a widget with eight buttons that are supposed to send an integer to a blueprint manager that sends it to an array of actor turrets. This integer will tell the turrets what to look at.

I have my turret blueprint actor here that will take the integer given to it and search an array of targets and get the transform it is supposed to use and set the actor to rotate and face where it is supposed to look.

I have a blueprint interface here that has an integer input


This is where I am at trying to figure out why when i click a button from the widget how to get it activate or preform its look at function in the actor. this right here on begin play or on event overlap with the collider from the manager will result in

all of the turrets looking at the first base. yet no buttons pressed will get them to change their target. they only ever go to the first base.

So how do I get it to wait for me to press a button and then do what it does on event begin play or on component begin overlap, and then do it again when I press a new button? Am I missing the right event to use, are my buttons sending integers to the manager and getting the right number to the turrets?

I’ve asked google AI and gotten far enough to get it to do this much within a BP_Turret Actor and Terminal UI widget.

Later I asked the developer assistant on the unreal engine page and got it to work this far including a BPI_ Rotate Actor, and a BP_Manager.

I added a box collider and a on component begin overlap following this https://www.youtube.com/watch?v=rM1tg6kYgn4 but even still the buttons do not result in the turrets changing.

I have ensured the buttons work by adding breakpoints to them and they are clickable they just do not do what I expect them to do. Change the turrets target based off the number they send.

I saved the AI notes

Hey @MiXDMAT!

This is typical AI confusion. AI is not always good for coding as not only can it do things in a very bloated way, sometimes it’s just straight up wrong.

You should never need to use BOTH an event dispatcher AND a blueprint interface.

In this case I would get rid of the interface completely. The code you have there off of “Event Receive Rotation Int” is good, but as it’s using an interface instead of a dispatcher, get rid of the red node.

Go back to the widget blueprint, and follow these directions. You do not need an extra actor to manage the turrets, just set the turret blueprint up to bind to the event. These instructions are accurate enough, I think, just try to be VERY specific and accurate to these here.

Again, remove the Interface and the manager. It’s just adding confusion, because each one of these things would be doing the same job and in my opinion dispatching from the UI is the most efficient thing to do here! :slight_smile:

Thanks for the Reply @Mind-Brain !

this suggestion is similar to what i started with before adding the manager and the blueprint interface it still just looks at base one on start and doesn’t change when any of the buttons are pressed.

for the create widget actor reference i had an array to all the turrets

So I made it again this time with a UI reference to self the blueprint actor but unless the execute pin comes from the bind event to on Base Selected. They wont even face the number one base. Still none of the buttons work to reface the turrets toward any other base when clicked.

If this is on each turret actor, you are creating a new Terminal UI Widget for EACH one of them. They’re probably overlapping, which is an issue and will likely make it appear normal but not functioning.

The white execution line needs to come from your “CustomEvent_0”. Otherwise the Dispatcher does nothing.

It’s behaving in that way when you bypass it because it’s automatically activating on BeginPlay, with a “0” on the Target Base, giving it the first integer. If you want it to operate by button it HAS TO be set up in this way (the way it is in this picture without corrections)

Try putting a “PrintScreen” node where you want to make sure the signal is reaching, such as after “CustomEvent_0”. Then you can track where the execution line is reaching.

The issue is most likely the creation of the Terminal UI widgets using the turrets. Maybe do this on the player? Or just simply somewhere where they aren’t going to create one per turret?

One way to test this would be to have a single turret. If it works with a single turret then this is the problem. Also can you interact with the Widget at all? Try putting printscreen nodes on the button code so it tells you when a button is pressed!

Good catch on the ui widget getting created by each turret @Mind-Brain !

I added some print screens to see where the code was reaching the only print strings that would show anything were the on clicked buttons so I decided to try writing the bind event on it too with some extra print strings to see if they would get through the event execute.

They did but they interacted oddly. No functionality came from binding the event in the Ui, but When I would click any other button than one or five or eight it wouldn’t print anything. Then if I clicked button one any button I selected afterwards would have a print string attached to it with the same context as if it had a print string the same as number one. 0 buttons, 1 buttons, 2 buttons, and so on. If I selected number five it would give any button i selected afterwards hot dogs. button 2 would show 1hotdogs, 2 hotdogs, 3 hotdogs, ect. If I clicked both of them it would print both 6buttons 6 hot dogs and so on. Button eight only had a print string executed after call on base selected. saying, “How about this one?” to which after button one and five were selected would say 7 buttons, 7 hot dogs, how about this one, but wouldn’t give any other button “how about this one?”.

Other than the print strings this bind event didn’t result in any changes to the turret. I moved the create widget to the terminal blueprint actor where the widget is shown. I also moved the bind event to this same event page since it doesn’t like to be anywhere other than where the widget is created. I can skip the button press and the turret (now only one) will face towards base 1 and when it comes from the bind event execute pin it results in no button selection resulting in anything but an oddly adaptive print string.

So let’s go into more detail on what Binding an event is. :slight_smile:

When you “Bind Event to On Base Selected”, what that means is “Every time ‘On Base Selected’ runs, also run this”.

So what you are doing is binding an event to “On Base Selected”, and then every time On Base Selected runs after that, it does the print strings. If you want to use it for each button press individually, you want to use a custom line of code OR just use “Call Event ______”.

As far as the turrets not moving, what code have you changed there? They need to have a reference to this widget still, to activate them when the widget button is pressed! :slight_smile:

I haven’t changed much here on the turret blueprint. Just got rid of the create widget. I still have the variable from when it was created here. Not sure where or how to plug this into it. Use an event begin play or an event tick? How should I reference it get all widgets of class, cast to widget? I’m not sure why it needs a reference to the widget other than getting the number for the transform array.

which from my understanding should be happening here within the blueprint terminal actor with the event bind. Button gets pressed → bind event here gets the number sends it to the function set target base → received by each turret to run event set target base. It creates the widget so it has a reference to it. and it has a reference to the one index array of turrets and i also tested it with just the solo object turret.

Okay, I’m following you here until this point:

How are you setting the array of turrets? Also as it is an array you want to use “ForEach” so it does each one, idk how that’s even connected and not an error

@MiXDMAT Did you get it all figured out? Let us know what you did and where you’re at! :slight_smile: