- Home /
 
 
               Question by 
               BlueTyrant · Oct 17, 2020 at 07:16 PM · 
                2d game2d-platformermovement script  
              
 
              Is there a way to make movement feel movement not feel slippery?
What I mean is, when my character moves it feels slippery like they still move after you let go of the move button
This is my script using System.Collections; using System.Collections.Generic; using System.Threading; using UnityEngine;
 public class Movement : MonoBehaviour
 {
     //Grounded Value
     bool isGrounded = false;
     Rigidbody rb;
 
     void Start()
     {
         rb = GetComponent<Rigidbody>();
     }
 
     void FixedUpdate()
     {
         if (Input.GetKey(KeyCode.A))
         {
             rb.AddForce(-1000 * Time.deltaTime, 0, 0);
         }
         if (Input.GetKey(KeyCode.D))
         {
             rb.AddForce(1000 * Time.deltaTime, 0, 0);
         }
         if (Input.GetKey(KeyCode.Space) && isGrounded)
         {
             rb.AddForce(0, 10000 * Time.deltaTime, 0);
         }
     }
     void OnCollisionEnter(Collision collide)
     {
         if (collide.gameObject.tag == ("ground"))
         {
             isGrounded = true;
             Debug.Log("Grounded");
         }
     }
     void OnCollisionExit(Collision collide)
     {
         if (collide.gameObject.tag == ("ground"))
         {
             isGrounded = false;
             Debug.Log("Airborn");
         }
 
     }
 }
 
 
              
               Comment
              
 
               
              I noticed that you're making a 2D game, but you're using 3D Physics. Is this intentional?
Yeah, i don't know why, but i feel it is easier to code physics in 2d if you use 3d objects
 
               Best Answer 
              
 
              Answer by GilJoWal · Oct 17, 2020 at 07:33 PM
There are other ways to make GameObject move such as Translate or Lerp, which should avoid this "slippery" behavior.
Answer by CDAXRC · Oct 19, 2020 at 08:02 PM
You need to assign physical materials for platforms https://docs.unity3d.com/Manual/class-PhysicMaterial.html
Your answer