Interactive dashboard button

Hi

How i can make so if i click e.g “E” anywhere in world it will perform action “lights_on”
and if click my mouse over button in dashboard, it will perform same action. But if i click any where else then over that button, nothing happens. Like in few simulator games like fernbus simulator, train simulator etc…

Thanks :slight_smile:

All you have to do is to call the same function or event using E and the dashboard button.

Your dashboard is a UMG widget, right? Then you have an event called something like Pressed/Clicked/OnPress. From that event you can use an event dispatcher to call your event. You can also give the widgeta reference to the object that has your function and call it that way.

Then you can either handle the input of E in one class like the player controller and call the function/event from there or you can handle the event inside the object with the function itself. Remember to bind E in project setting and enable input in the object that you handle the keypress in. Just search for event E and it should come out.

Now you have to make the event or function you are calling turn the light on, turn them off or toggle them.

Hope it helps.

thanks for answer, but my dashboard is 3D object. Like cars have, so not widget

You could try to use OnClicked event.

Please change this answer to a comment by pressing the down arrow and select convert to comment.

Could you show me a picture of what you have please? That way I can understand better and thus help you more.

So if i have bus dashboard like this one, i can click any of these buttons with my mouse. Or press e.g D to change gear to Drive mode (D,N,R are gears)

Then you have to find out what is under your mouse. You can do that by using a get hit result under cursor by channel node. Then, once you break up the hit to get the actor you can call the function you want inside the button actor.

That is my current blueprint in “My character”

And my setup in engine, but now if i click those light objects too (grey cubes) it changes the material. It should only change if i click that switch object. Also how would i make that i can press e.g E too to change material

You have to make different actors for each button. If you have 3 buttons you have to add 3 button actors into your character blueprint. Each button must have its own collision. Then your setup should work.

yea, but in this case i have only one button and those three grey boxes should change material. After i click that one black button. And now if i click grey lights they change material, which should not happen by clicking them only from that black one. And i cant get it figured out how to do it