Describe the problem: So my player is stuck to the wall when he jumps and moves to the right side at the same time. Watch the video below to imagine it better.
Watch the video for better illustration: HERE
If there is anything to do with code, here is the PlayerMovement script:
public class PlayerMovement : MonoBehaviour
{
Vector2 vector2Move;
Rigidbody2D rb2D;
[SerializeField] float playerSpeed;
bool isGrounded;
Collider2D playerCollider;
float theCurrentGravityScale;
private void Awake()
{
rb2D = GetComponent<Rigidbody2D>();
playerCollider = GetComponent<Collider2D>();
}
void Start()
{
theCurrentGravityScale = rb2D.gravityScale;
}
void Update()
{
Run();
}
void OnJump(InputValue value)
{
if (playerCollider.IsTouchingLayers(LayerMask.GetMask("Ground")) && value.isPressed)
{
rb2D.velocity += new Vector2(0f, jumpForce);
animatorPlayer.SetBool("isIdling", false);
}
}
void OnMove(InputValue value)
{
vector2Move = value.Get<Vector2>();
}
void Run()
{
animatorPlayer.SetBool("isRunning", true);
Vector2 playerMovement = new Vector2(vector2Move.x * playerSpeed, rb2D.velocity.y);
rb2D.velocity = playerMovement;
}
private void OnCollisionEnter2D(Collision2D collision)
{
animatorPlayer.SetBool("isGrounded", true);
}