I would like to achieve this:
Let`s say I have 3 different actor blueprints containing an individual object (for example 1=chair in red, 2=chair in green, 3=chair in blue).
Now I have 3 buttons in a hud, clickable by the mouse. By clicking button 1 the red chair appears in my level, by clicking button 2 the green chair
appears AND the red chair disappear and so on. So I always see only one chair, choosen by the buttons.
Is there an pretty easy way to do this ?
By the way, I know there is a way to change colors with a dynamic material instance, but this is not the goal. I want to switch through the objects.
A hard cut (visible on/off) is enough.
Thanks a lot and bye
You could just have one actor blueprint with one static mesh component. On the button click call an event on the blueprint and pass the static mesh you want through a static mesh input on the custom event. On the custom event on the actor, set the static mesh component to what you sent through the input.
there are several ways you can do this. You can either make a blueprint for each of them . then create a sort of spawn in system that would use a widget button to spawn them in. This method is more complicated to set up though.
Another easier way you could do this is just already have them in the level. Add them to an array or create references to each of the mesh then you simply use a button or several buttons to toggle the visibility.
eg click the button once, this sets red chair to visible and sets green and blue chair to invisible
click the button again, this sets blue chair to visible and sets green and red chair to invisible etc etc
here you go just a quick demo project i threw together .
press the B key on the keyboard for blue cube
press the R key on the keyboard for the red cube
press the G key on the keyboard for the green cube
i used keyboard keys just to show you . you should be able to work out from my example how to use buttons to do the same thing instead.
hope this helps
sorry forgot to post the link lol ^___^
or blueprint screen shot if you prefer to do it yourself
While this may work fine in his situation (cubes), you won’t want to do this if your meshes are in different locations, or are different shapes. Setting an actor to be hidden will not disable it’s collision, but merely hide the actor. You could disable collision after setting it to be hidden, but personally I would spawn/destroy the actors.
Yeah true mate but he didn’t ask about collisions all he wanted was to show or hide the chairs (cubes) on button press so I gave him the simplest and easiest example way to do this.
But It all depends what he wants to use it for really. Also to change the code to spawn the actors instead wouldn’t be that difficult .
Hey this is cool Many thanks to you.
I will try this and give you feedback.