|
Is it possible to emulate keyboard keys with a gui button? I want to move my character with a 4 gui buttons, but instead of re doing the input script, is there a way to map a gui button to simulate a keyboard key? Like if I were to press a button, then it would do what the "w" key does, and move forward. It seems simple to do I just haven't been able to find a way to simulate a keyboard input.
(comments are locked)
|
|
I've not found any way to fool Unity and make it "think" a key was pressed, but you can create a function to substitute Input.GetAxis, for instance. Add the code below to the script where you read Input.GetAxis("axis"), and just remove the dot to transform the original function calls in InputGetAxis("axis"): Use this InputGetAxis like the conventional Input.GetAxis, like below: Thank you very much, though I'm getting a parsing error hopefully I can get this working soon, appreciate it! Its just silly that theres not an easier way to emulate keys.
Jul 14 '11 at 03:32 AM
WillModelForFood
Aldo Naletto thank you so much <3
Apr 01 '12 at 04:17 PM
jesusluvsyooh
Ah, this was great! Thank you.
Oct 24 '12 at 04:49 PM
Enkendu
Awesome the GUI.RepeatButton Handles many same problems!!
Dec 03 '12 at 03:17 PM
behzad.robot
Thank you Aldo Naletto, thank you very much. :-) you saved my day. thanks a lot.
Dec 21 '12 at 06:21 AM
DewDrop
(comments are locked)
|
|
my god "Aldo Naletto" thank you so much, spent absolutely ages trying to get something on the lines of this working, <3
(comments are locked)
|
It's the same thing: copy the code above at the beginning of your script and remove the dot from Input.GetAxis: transform.Rotate(Vector3.down, InputGetAxis("Horizontal") * rotateSpeed * Time.deltaTime); NOTE: there's a rule in Unity Answers: only use answers to answer to questions; in this case, you should have posted it as a comment in my answer (or as a new question). You may think: Why nobody told me that before?, and I would agree: there should exist some kind of omnipresent warning about this!
Jul 18 '11 at 04:48 PM
aldonaletto
sorry , it's my first reply.
Jul 18 '11 at 05:18 PM
ermenda
don't mind, everybody makes this mistake at the first time!
Jul 18 '11 at 07:49 PM
aldonaletto
is there any way to multiple key input at a time from virtual keys?
Jan 01 at 08:46 AM
DewDrop
(comments are locked)
|
