Player Vibration on collision - AddForce Vs transform.Translate
Hello so ive been trying to make a player controller, everything is good but when the player collides with a 2d Collider he vibrates into it, i understand that its because transform.Translate teleports the player i found a fix online which is AddForce, it worked good but it adds force continuously making the player faster and faster. is there any way i can make it so AddForce only stays on one? or transform.Translate doesnt teleport the player into 2d colliders?
Here are the scripts i use AddForce:
 if(Input.GetKey(KeyCode.D)||Input.GetKey(KeyCode.RightArrow))
         {
             GetComponent<Rigidbody2D>().AddForce(Vector2.right * NormSpeed);
             if(facingRight == false)
             {
                 FlipPlayer();
             }
         }
         if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
         {
             GetComponent<Rigidbody2D>().AddForce(Vector2.left * NormSpeed);
             if (facingRight == true)
             {
                 FlipPlayer();
             }
         }
 
               transform.Translate:
 MoveX = Input.GetAxis("Horizontal");
 
         var x = MoveX * Time.deltaTime * Speed;
         {
             transform.Translate(x, 0, 0);
         }
 
         if (MoveX < 0.0f && facingRight == true)
         {
             FlipPlayer();
 
         }
         if (MoveX > 0.0f && facingRight == false)
         {
             FlipPlayer();
         }
 
              Your answer
 
             Follow this Question
Related Questions
How to add limited player movement on grid? 2 Answers
Getting 2D Turrets to rotate toward bullet direction. 1 Answer
2D AI movement 0 Answers
What is wrong with this script? 3 Answers
Working with a 2d movement in a sidescoller style? 0 Answers