- Home /
Horizontal as a NGUI button
Hi everyone, I have a script that rotates a gameobject with Input.GetAxis("Horizontal". Now I want to make two NGUI buttons for rotating it instead of the horizontal input.
screenRotation += -1 * Input.GetAxis("Horizontal") * RotationSpeed;
this is the part that rotates the Gameonject.
I tried using a static float variable that changes to 1 if the right button gets pressed and to -1 if the left button gets pressed.
Static variable on the rotate script:
public static float horizontal = 0f;
Ngui button Script
public void left ()
{
ScreenController.horizontal = -1f;
}
public void right ()
{
ScreenController.horizontal = 1f;
}
But this doesen't really work how it should.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613174856im_/https://answers.unity.com/themes/thub/images/avi.jpg)