I made an object with ridgedbody2d and addforce
It moves well normally but It stop sometimes and sticks on the platform like a gum
I checked Input.GetButton(“Hrizontal”) and the Keyboard is alright
I also monitored " rigid.velocity.x " and it goes like "0 → 0.1 → 0.3 → 0 → 0.1 → 0.3 → 0 "
the velocity normally should be “0 → 0.1 → 0.3 → 0.6 → 1 → 2”
my script is as below
using UnityEngine;
public class Playermove : MonoBehaviour
{
Rigidbody2D rigid;
void Awake()
{
rigid = GetComponent();
}
void Update()
{
Debug.Log(rigid.velocity.x);
float h = Input.GetAxisRaw("Horizontal")*Time.deltaTime*20;
rigid.AddForce(Vector2.right * h, ForceMode2D.Impulse);
}