Using on screen buttons as "horizontal"

To make controls that are like arrow keys on a computer, how do you do that virtually?
The “horizontal” controls on pc are arrows but can those be used as virtual buttons for an iphone?
I want to know so i can make a game with a car and not use tilting to do steering and acceleration.
so like one button steers left and the other steers right.
Any suggestions please. :slight_smile:

You can just use GUI Buttons, which you can apply left/right arrow images to, or simply “L” and “R” initially to test.

See the GUI guide here:

http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html

Thanks for the Gui guide, that will be useful, but as far as controlling the game i dont know how to replace the horizontal (currently accelerometer) with a button

So you have existing code that uses the accelerometer to do the movement?

yes but i want to make the accelerometer be buttons instead, so i was trying to replace the horizontal input.

You should be able to just do something along these lines then:

function OnGUI() {
    if (GUI.RepeatButton(Rect(0, 300, 20, 20), "L")) {
        // The code that is currently executed when detecting the left movement on the accelerometer
    }
    if (GUI.RepeatButton(Rect(460, 300, 20, 20), "R")) {
        // The code that is currently executed when detecting the right movement on the accelerometer
    }
}

Ok thanks! Ill try that

Hi there, currently trying the same at the moment. I am needing to have the Left/Right arrow functionality on a button. Is there anything like this around or do I need to create that programatically? or are you able to convert the getAxis to a button?

Thanks

Chunk