Player stuck on walls and/or colliders

Creating a game (duh) but I’ve run into a small “bug”. It’s not “game breaking” but I would like to fix it “relatively soon”. Am I using too many “quotation marks”?

The problem is when the player jumps into a wall or an object with a collider and keeps moving forward/walking, they become stuck in the object until the walk button is let go.

It also seems to affect when walking into an object with a circle collider, in which case the player magically walks up the object.
The video shows what I mean.

Here is my player controller script. I’m fairly new to Unity and I have little to no programming experience, merely been cobbling together code from different tutorials around the web. Any and all help would be greatly appreciated. <3

using UnityEngine;
using System.Collections;

public class PlayerControl : MonoBehaviour
{
    public float maxSpeed = 10f;
    bool facingRight = true;

    Animator Anim;

    bool grounded = false;
    public Transform groundCheck;
    float groundRadius = 0.2f;
    public LayerMask whatIsGround;
    public float jumpForce = 125f;

    void Start () {
 
        Anim = GetComponent<Animator> ();
    }

    void FixedUpdate () {

        grounded = Physics2D.OverlapCircle (groundCheck.position, groundRadius, whatIsGround);
        Anim.SetBool ("Ground", grounded);

        Anim.SetFloat ("vSpeed", rigidbody2D.velocity.y);





        float move = Input.GetAxis ("Horizontal");

        Anim.SetFloat ("Speed", Mathf.Abs (move));

        rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);

    if (move > 0 &&!facingRight)
                        Flip ();
                else if (move < 0 && facingRight)
                        Flip ();
    }

    void Update()
    {
        if(grounded && Input.GetKey ("space")) //CHANGE GETKEYDOWN

        {
            Anim.SetBool("Ground", false);
            rigidbody2D.AddForce(new Vector2(0, jumpForce));
     
        }

        }

    void Flip()
    {
        facingRight = !facingRight;
        Vector3 theScale = transform.localScale;
        theScale.x *= -1;
        transform.localScale = theScale;

    }
}

Make a Physics2D material and set the friction to be 0. Attach it to your object that youre having trouble with.

2 Likes

It worked. Thank you.

Well, im glad to hear that.:slight_smile: