Mapping iOS touchscreen as simple buttons

I am having a really tough time figuring out how to map a touch on the screen to do certain things.

I figured out how to make the entire touchscreen on an iPhone act as the jump button, but I would like to split up the screen into different sections:

Left half: Jump
Right Top half: Accelerate
Right Bottom half: Deccelerate

I wish I had some code already implemented that were giving me errors but I haven’t come across what I’m trying to look for at all. I don’t need to render any GUI and I need this function to occur during function Update() { }.

If anyone could at least point me in the right direction that would be muuuuch appreciated! I apologize for the lack of info but I’m really not getting anywhere yet after a couple hours of researching and messing with scripts.

Thank you so much for reading and if you have any questions before you come up with anything feel free to ask anything.

Input.touches will give you a set of Touch structures representing all current touches. Each touch has a position field, along with some other very useful data. Read up a bit on it.

You can compare a touch position against Screen.width and Screen.height to determine where on the screen the finger is touching. Left half, right half, and so on should be very easy to calculate with this method.

If you need to figure out what in the world your player is touching, you could convert the touch to a Vector3 and use Camera.ScreenPointToRay() and Physics.Raycast(). This is potentially useful for clicking on “button” objects which you can actually represent using in-world colliders, or for picking other game objects directly.

hello @rutter can i ask you a question…?

Is there a way to test a android/ios game without a device…

I hope you will reply…

thanks