Widget button to toggle meshs visibility

Hello everyone,

I’m getting mad at this problem. So I’m sitting at them moment on a clicker game, and I’m working current on the Buttons.

One Button is to toggle the visibility from a Mesh. If I have only one mesh it works great, but I want that every time I click the button the last mesh get invisible and the next will visible. Like an upgrade from a tower in TD game.

Is that right, that I only have access, to the visibility, with Tags to my meshes, in my Widget blueprint (get all actors with Tag) ?

5 days of trying and no result. Thanks for every answer.

Hello! You can store mesh actors array in BP and also store some index value. So for button click you just make mesh with current index invisible, increment index and then make mesh with this index visible. Loop index incrementing with mod and that’s it

Thx for the reply. Ok i try to learn how arrays work. At the moment I try to make a big if then else loop, but i think it can be too expensive.

I click the button the last mesh get
invisible and the next will visible.

Wouldn’t it make more sense to swap meshes rather than show / hide them?

Pseudo-script:

Every time you click, index goes +1 and fetch new mesh from the select node. Would that work? Am I even close?

THX for your reply and it works. But I have here one issue, what if I have more meshes to swap at the same time. For example, I build “tower 1” to maximum level 10, then I want to start a second tower next to him, after clicking the same button again. And if I have 6 towers then I want to remove them and place a super Tower for them. Can I achieve this with your node example?

Hard to advise more precisely as I do know know how the towers work. As in, is every tower a new actor or we’re spawning more? Is the Mega Tower the same actor or a newly spawned one.

This could work in so many ways.

For example, I build “tower 1” to
maximum level 10, then I want to start
a second tower next to him, after
clicking the same button again. And if
I have 6 towers then I want to remove
them and place a super Tower for them.
Can I achieve this with your node
example?

This should do it:

Disclaimer: utterly untested