How can I make a touch button?

i need to make a touch button (not joystick).

Howdy!

Maybe post some pics or examples of what you are after so the community can better assist and more detail as to what you want your button to do.

-W

Do you mean a touch button that is used with mouse interface activated?
Can’t really understand either what you want to do.

Please provide some more information so we can get you on the way!

  • Oscar Hvarfvén

I am making a mobile game. I have already added touch joysticks and now I need to add some buttons.

how did you create the joysticks?

By creating a new touch interface

Can you post your touch interface please? I am trying to make a touch interface for my game but I am freaking out. That would be so extremely easier if you could set the x and y values via mouse on an virtual touch display.

this is my touch interface

Okay, thanks, that helped me. Hopefully you will find an answer right fast. If I am right, u only want a button and no stick which can be moved while touched, right? You could create a mesh and add OnInputTouchBegin Event. Problem is: That did not work for me ^^

Hm… That’s not working for me. Do i need to set the Touch Interface to None?

  1. Make a new Actor Blueprint that is going to be holding all of your buttons
  2. In the Components tab of the blueprint, add a new Scene Component (its just a empty actor with position so that you can move the blueprint around around its axis)
  3. Add a Box component
  4. Add a Text Render component or a Static Mesh component (based on how you want the button to look)
  5. Change the size of the box to make the Text/Static Mesh fit nicely inside of it
  6. Set the Collision Preset of the Box to Custom
  7. Expand the Collision Presets and set everything except for Visibility to Ignore and then set Visibility to Block
  8. In the Graph>EventGraph tab, select the Box from the pane on the left
  9. Right Click in the graph and add a OnInputTouchBegin event
  10. Connect it to what ever action you want to happen on click (for example a Print String node, for testing)

If you want the button to work with mouse inputs too, you need to connect a OnClicked event to the same action as your OnInputTouchBegin.

Oh, i made a mistake with the Collision Presets, weird tho, i edited my answer but it changed back…set the Collision Preset to Custom and set everything except for Visibility to Ignore, set Visibility to Block.

Do I need to set Auto Receive Input to Player0 for the Blueprint? Still not working. Or I am doing something terribly wrong ^^

What is and isn’t working?

I created a Blueprint with a Box and a static mesh. I added the OnInputTouchBegin-Event and connected it to a print string node, which should print “hello”. I launch the project on my smartphone but nothing happenes when I touch the mesh.

Does it work when you test it in the editor? Do you know TeamViewer? I could see your monitor and control your mouse with it and see whats wrong.

Nope it’s not working in the editor. For TeamViewer: . I will show it to you. Maybe you will find something ^^

Got it! I need to make a GameMode Blueprint. Than I can set a Player Controller Class (which is a BP, too). World Settings → Game Mode → Player Controller Class → Choose the BP. The Plaeyr Controller BP has some settings like Enable Click Events and Enable Touch Events. Now it works! Thanks Benjiko99 for your help :slight_smile:

Ah, thats great :slight_smile: and you might wanna delete your TeamViewer ID from here :smiley:

Benjiko99, I have a question, since I cannot get mine to work:

Once you add the collision box in the Blueprint…how does that get into the actual scene?

Or, once you add the render text in the Blueprint…how does THAT get into the actual scene?

Do you know of an online tutorial that shows this? It seems like it should be completely easy, but I’ve been working on it for almost three days, and can’t even click on an object!

Thanks.