Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to make a racing game on android using unity. I want to make a car move forward when I touch an image button like in the picture below. I've already made it work using the keyboard. How do I do the same with on-screen buttons and touch input in android?

example touch interface with buttons

share|improve this question

If you are using Unity 4.6+ then you have access to its new UI system. If you ever used NGUI, which is a popular unity UI frame work, its based on that architecture I believe.

This is a good tutorial on the subject of buttons and how they work.

http://unity3d.com/learn/tutorials/modules/beginner/ui/ui-button

Quick summary tho:

  1. In the scene create new and select UI->Button
  2. Select the new button in the scene and find its Button script in the inspector
  3. Make a new on click event
  4. Assign the object you want to act on when the button is press and the function to call (whatever your current movement code is)

At step #2 if you want to listen for more specific events just add a new EventTrigger script and pick a more specific event type and set it up by assigning an object and callback.

More on that here: http://unity3d.com/learn/tutorials/modules/beginner/ui/ui-events-and-event-triggers

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.