I currently have my character moving with WASD. I have a GUI setup that I want to mimic the WASD movement. I was wondering if it were possible to have a function say if GUI Button pushed, then act as if Input.GetKeyDown(“x”) = true.
I’d like to do this because it’s an easier way to do what I want, plus I’d just like to know
I have an on-screen WASD control that lets you push the buttons as though they were keys. I don’t know if it’s the best way, but what I did was use GUI.RepeatButton’s and modified the MouseLook and FPSWalker scripts to have a new var like ‘doVert’ and ‘doHorz’ to accept these as though they were Inputs.
A fragment:
if (ml == null)
ml = Camera.main.GetComponent(MouseLook);
if (GUI.RepeatButton (Rect (Screen.width - left, Screen.height - top, 44, 44), laTexture))
if (ml)
ml.doHorz = -.10f;
You can have a function named “W” that when you press the W key, do that function.
Then you can have a GUI button that if it is pressed, do that function.