If the player jumps into a wall and keeps holding the d or a key(depending what side of the game the wall is on) they will just stick to the wall.
Is there any code that could prevent this?
my code for the player:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public float speed;
public float jumpSpeed;
bool grounded = false;
public Transform groundcheck;
float groundRadius = 0.2f;
public LayerMask whatIsGround;
void FixedUpdate()
{
grounded = Physics2D.OverlapCircle (groundcheck.position, groundRadius, whatIsGround);
if(Input.GetKey(KeyCode.D))
{
rigidbody2D.velocity = new Vector2 (speed, rigidbody2D.velocity.y);
}
else if(Input.GetKey(KeyCode.A))
{
rigidbody2D.velocity = new Vector2 (speed*-1, rigidbody2D.velocity.y);
}
else
{
rigidbody2D.velocity = new Vector2 (0, rigidbody2D.velocity.y);
}
}
void Update()
{
if(grounded && Input.GetKeyDown(KeyCode.W))
{
rigidbody2D.AddForce (new Vector2 (0, jumpSpeed));
}
}
}
Thanks in advance.