- Home /
game snake move
how can I make sure to tell my object when I press the right arrow he must go infinitely right? and when I click the left must do the opposite? I have tried using if (Input.GetAxis) but right when I remove your finger from the button stops this is the script:
#pragma strict
function Start () {
}
function Update () {
if(Input.GetAxis("Vertical")>0){
transform.Translate(0,0,5.0*Time.deltaTime);
}
}
Answer by emongev · Mar 21, 2013 at 08:36 PM
You could have a "last direction pressed" of sorts, and instead of using the vertical axis on the Input directly, use the Input to change the last pressed direction, and use the traslate at all time (outside the If input statement) using the last direction pressed.
Your answer
Follow this Question
Related Questions
Code Not Working 1 Answer
Left Shift being cancelled by left control? 1 Answer
Trying to stop object snapping to a position 2 Answers
moving starfield with gameobject prefab list 1 Answer
Lerp Gameobjects.. 1 Answer