- Home /
Fluid motion not working on input
I want my character to move sideways when pressing two keys at the same time. a + e or d + e, the input works, but the character moves just one step. It doesnt continue moving, here is the script:
if (Input.GetKeyDown("a") & Input.GetKeyDown("e"))
TP_Motor.Instance.MoveVector += new Vector3(Input.GetAxis("Horizontal"), 0, 0);
if (Input.GetKeyDown("d") & Input.GetKeyDown("e"))
TP_Motor.Instance.MoveVector += new Vector3(Input.GetAxis("Horizontal"), 0, 0);
The script that moves the character forward and backward works fine. Can you tell me why the difference?
FORWARD AND BACKWARD MOTION:
if (Input.GetAxis("Vertical") > deadZone || Input.GetAxis("Vertical") < -deadZone)
TP_Motor.Instance.MoveVector += new Vector3(0, 0, Input.GetAxis("Vertical"));
Answer by vatara · Jul 17, 2013 at 06:22 PM
You're using Input.GetKeyDown which is only true when the key is first pressed, not while it's held down. You probably want to use Input.GetKey which is true as long as the key is held down.
You are absolutely and totally right. It works now. THAAAAN$$anonymous$$S!!! I was going to commit suicide soon haha. But now the script works.
Your answer
Follow this Question
Related Questions
Check where mouse is clicked 1 Answer
endless runner game help 2 Answers
How can I get the x position for the left(and right) of the screen? 2 Answers
left/right rotation force 0 Answers
Using Accelerometer to move and rotate a 3d cube from left to right 0 Answers