- Home /
              This question was 
             closed Oct 08, 2015 at 03:34 PM by 
             Dicklett for the following reason: 
             
 
            The question is answered, right answer was accepted
Adding a slide/velocity effect to a non-rigidbody2D object
I have the following code that tries to reproduce the velocity effect:
     if (Input.GetKey(KeyCode.A))
     {
         transform.Translate(Vector2.left * velocity * Time.deltaTime);
         velocity++;
         if (velocity > maxSpeed)
             velocity = maxSpeed;
         anim.SetTrigger(moveLeftHash);
     }
     else
         velocity = 1;
     if (Input.GetKey(KeyCode.D))
     {
         transform.Translate(Vector2.right * velocity * Time.deltaTime);
         velocity++;
         if (velocity > maxSpeed)
             velocity = maxSpeed;
         anim.SetTrigger(moveRightHash);
     }
     else
         velocity = 1;
     if (Input.GetKey(KeyCode.W))
     {
         transform.Translate(Vector2.up * velocity * Time.deltaTime);
         velocity++;
         if (velocity > maxSpeed)
             velocity = maxSpeed;
     }
     else
         velocity = 1;
     if (Input.GetKey(KeyCode.S))
     {
         transform.Translate(Vector2.down * velocity * Time.deltaTime);
         velocity++;
         if (velocity > maxSpeed)
             velocity = maxSpeed;
     }
     else
         velocity = 1;
Normally, this should start moving the player with speed of 1 and the gradually build it up to maxSpeed, which is 10. The problem is that the speed remains 1 constant and I have no idea what is causing it. Any help/tips is appreciated. :)
               Comment
              
 
               
              Follow this Question
Related Questions
Character won't move (Fixed) 1 Answer
Stopping an object immediately 1 Answer
Need some help with my dash move 1 Answer
Smooth movement using Rigidbody2d 3 Answers
Object jitters when the scene starts 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                