- Home /
How to alter input to continuous rather than tap?
My code works perfectly in rotating a cube around both axis' (axees?) My problem is that you have to continuously tap a key to get it to move in the desired direction, how do I make it so that holding the key down moves it in that direction continuously, rather than just once, and at the same speed.
Code:
var speed = 5000;
function Update ()
{
if(Input.GetKeyDown("left")){
transform.Rotate(0, 0, Input.GetAxis("Horizontal") * speed * Time.deltaTime,Space.World);;
}
Also, that "var speed = 5000" doesn't actually seem to be changing anything, thats why it's at such an insanely high number. How do i speed up the rotation?
I never programmed in unityscript so this might be wrong.
var speed = 5000 is public variable that can be accessed and set from inspector in unity editor. If you set value there, changes in code wont have any effect. (at the initialization that is)
Answer by Piflik · Jan 03, 2013 at 12:06 AM
GetKeyDown() is only true for one frame. If you want to hold the button down, use GetKey().
Also don't post the same question multiple times. Sometimes it can take a bit until a new question is published by a mod. Please be patient if a question doesn't appear immediately.
Oh, sorry if i re-posted, it's because my browser is running slow, so i was waiting for it to post. Also, THAN$$anonymous$$S. Solved my Problem =]
Your answer
Follow this Question
Related Questions
How to alter input to continuous rather than tap? 0 Answers
How to alter input to continuous rather than tap? 0 Answers
How to get the key from the button name 1 Answer
[Unity5] Rotate UI button with mouse/finger 2 Answers
Key remapping inGame 0 Answers