Toggle widget visibility?

Can I get one actor to toggle the
visibility of a widget of another
actor?

  • Another Actor creates a widget and stores a widget reference:

  • One Actor changes Visibility of Another’s widget:


But I sense your question has less to do with widgets and more to do with actor referencing.

There are so many different ways of passing data between blueprints - you’ll need to very precise regarding what needs getting where and to whom if you need a concrete example.

To be more precise, Can I get one actor to toggle the visibility of a widget of another actor?

If so, how exactly?

Okay. I have a ship actor. I give it a widget component that is hidden in the game, and I want it’s visibility to be toggled on or off based on that ship actor.

The thing is, as a set up I have the other ships are all children of the one ship I made. Will this be a problem?

So if I press a button, the HUD should toggle on, displaying the widget component of the other ship, and should toggled off after I press it a second time; hope that’s good enough.

I have a ship actor. I give it a
widget component that is hidden in the
game,

Sure, makes sense.

I want it’s visibility to be
toggled on or off based on that ship
actor.

What does it mean?

displaying the widget component of the
other ship

Makes sense.

  • how many other ships are we talking about?
  • Is there only 1?
  • If there’s more, how are we selecting other ships?
  • how do we know which one?
  • how does this other ship come into play? Spawned dynamically or added manually to the map?
  • Yeah in this case it’s just one ship; would like to add more ships later down the line, but I need to focus on just getting one done first.
  • I don’t want the option to select other targets. I think that would make it a bit more complicated to I wanted to start with a simple goal of displaying the widget component of the other ship. So for now, it’s just one.
  • I at first thought you won’t really have to know which one to shoot at; just aim and shoot, like in an FPS. So it’s not quite like a Ace Combat or Air combat sim because while I want this for my game, it is not the ultimate goal of the project.
  • Ship or Ships are spawned dynamically.

I’m sorry I’m not being clear enough; I meant to say the widget component is the main obstacle here.
I already have the ships spawned on the map, plus I know how to spawn them in the game dynamically, So I think I’m set there.

What’s been bugging me is the widget component and getting the other enemy ships to display. on the screen or HUD. I hope I’m not losing you :slight_smile:

also about the second picture, I’m confused … so the player ship is spawning the enemy ship and the enemy ship is spawning the player ship, again???

Ship or Ships are spawned dynamically.

Wouldn’t that just work then:

Each ship can push data into another ship.

Or, if you must, create a reference of Enemy Ship in the Player ship and expose it:

Ship or Ships are spawned dynamically.

vs

I already have the ships spawned on
the map

So which one is it? Hope you understand my confusion :slight_smile: These two statements contradict.


If both ships are already on the map, the communication is trivial:

  • create a reference to the enemy ship in the player ship - this way you can access the enemy’s widget

  • since both are already in the world, reference them:

No, you said that both ships are spawned dynamically… so that’d be the blueprint that spawned them.

Okay I tried it but it didn’t work; I will show my setup in few.

Here is my Ship(The Ship I control)

I might not need the Sequence Node but I just wanted to see if there’d be any difference.

And here is the Enemy Ship

Not sure why you’re posting all this but I can’t see anything I suggested here.

We’re talking about a single variable that you point at an actor in the world… and you’re done. Once you get it going, you can continue working with the rest.

Perhaps you should consider following what I proposed. Or you did and it does not work? Sorry, but I can’t see the critical bit above. Most of the script you’re showing is just not relevant at all.

Is it Ship Targets? Did you assign the enemy ship from the world? It’s the 2nd pic.

Could you show how you’ve assigned it?

Yeah I did it like you said and it didn’t work.

and yes the Ships Target is the variable for the other ship.

OMG I did not think of doing the print string part; my bad.

Yes Target indicator is the Widget component for the enemy

All of the other nodes used are not relevant, you’re right.

Okay so I managed to get the widget to display.

The Widget Component Rendering settings had Visible and hidden in Game both set to true, and I think that may have messed things up a bit. I cannot believe this, I feel so dumb.

alt text

Okay so I have one ship to display the widget; and you’re gonna hate me for this because I now want to be able to display the widget component for all the ships currently in the world. Now I realize what you mean by the Communication is trivial.

To do this I assume I’d have to use a for each loop and cast to node, but I know I’d be missing something here.

So I had an Idea, haven’t done anything with it yet but I would like some feedback on this: is it possible to have an actor that spawns a sphere that detects all the actors within the bounds of that sphere? This way I won’t be turning on all the widgets for every ship in the world, only the ones that overlap that sphere that was spawned?

I hope the point was to show me how to do it step by step by simple things first in small increments before getting to the more complex ideas because if so it is working,

it didn’t work.

This is not descriptive enough, sorry. If you need help, you really must try a bit harder. Grilling someone for info is no fun at all :wink:

So what exactly does not work? Use Print String, Breakpoints, Watch pin values and use Debug Filter to observe data flow. Did you try any of this? Do you see any warning / error messages in the log?

What is Target Indicator - the enemy’s Widget Component? Do the nodes fire? Is the widget set up correctly?

I now want to be able to
display the widget component for all
the ships currently in the world

If this is really what you need and you really mean all of them then Get All Actors of Class would work well. No casting necessary as this filters it out:

Select Class first and then connect the Loop.