I’m trying to make a system of button activated by raycast and who make appear or hide multiples objects when “pressed”.
I have the raycast who print me the name of the object who’s working but now I’m stuck, and I have no idea how to continue…
Ok so this is what I have now, when the raycast hit something, the object disapear an appear if I click a second time. The issue now is that I want that only when my raycast hit the “Button” mesh.
For that, I need to make a blueprint in any object I want to set visible or not ? Or a blueprint on the Button ?
The picture you replied at 678GUY the only thing missing is before the flip flop cast it to your button first, if it is a success then proceed to setting visibility if it returns fail do not do anything.
Just a last question about it, now if working when I click on one object (my Button). But if I need to do it whith differents buttons for diferents result, how can I make a “switch” function after mine LineTrace ?
I know you got your answer, but for a more modular approach look up interfaces. With interfaces you don’t have to do any casting at all. Right now you always assume the actor hit is the actor you want to hit. Just a tip if you want to expand your functionality in the future.
I have limited knowledge in UE4 this is the way I would do it. This might be not the most efficient way to do it, there might be other ways to solve it that is better than this.
I assume your button is only an actor in your level.
You make an array containing all your button reference. Arrangement in making the array is important.
After adding them to an array. Add this after your linetrace node.
Every time you click it will read your array and check all the buttons you placed there comparing it to the hit actor of the line trace, when the proper button was found it will continue to the switch on int.
0 is for the first item in the array, 1 is for the second, the rest follows.
For example button one will make something fly, you put the fly function on the 0 part of the switch on int. The second button will make something disappear, put the disappear function on the 1 part of the switch on int.
The default as the name implies the default function to be called when the integer range exceeds the declarations.
I reccommend you to make a blueprint that can be the parent of all your buttons and you can reduce that making of array to this. There arrangement would be the first blueprint you placed on the map will be the first item in the array.