Hi all,
I’m having issue with the 2D Edge Collider. Please refer to the following video or attached project.
The player is assigned a CircleCollider2D and can move left and right as well as jump while grounded. I’ve placed two different ground colliders (Polygon Collider and Edge Collider). However weird behaviour is occuring on the Edge Collider. Once the Player moves from a flat surface onto a curved the Grounded status is set to FALSE. This does not happed for the Polygon Collider or any other collider.
Any suggestions


using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
public float maxSpeed = 10.0f;// How fast character can go at max
private bool facingRight = true; //Facing Direction
private bool playerGrounded = false;
public LayerMask whatIsGround; //Stores all Layers that will be considered as Grounded
public float playerCircleRadius; // Gets the Players raduis
public Vector2 playerCircleCenter; //Gets Player Center position
private Animator anim;
public float jumpForce = 700.0f;
void Start()
{
anim = GetComponent<Animator>();
CircleCollider2D c_collider2d = gameObject.GetComponent<CircleCollider2D>();
playerCircleRadius = c_collider2d.radius ;
playerCircleCenter = c_collider2d.center;
}
// Update in sync with physics
void FixedUpdate ()
{
//GROUDED - Constant check to see if we are on the ground. The following will simpply return TRUE or FALSE
playerGrounded = Physics2D.OverlapCircle (gameObject.transform.position, playerCircleRadius, whatIsGround);
//Now we assign to the animation whether or not we are on the ground
anim.SetBool ("Ground", playerGrounded);
//JUMPING
anim.SetFloat ("vSpeed", rigidbody2D.velocity.y); //Determines how fast we are going UP / DOWN
//MOVEMENT - Following are used to control the player movement direction
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 ()
{
//The reason we put the jumping funcitonality inside Update() rather then FixedUpdate() is for accuraracy purposes
if (playerGrounded (Input.GetKeyDown (KeyCode.Space)))// WARNING - Change KeyCode to GetAxis specific key
{
anim.SetBool("Ground", false);
rigidbody2D.AddForce(new Vector2(0, jumpForce));
}
Debug.Log ("playerGrounded: " + playerGrounded);
}
//This function eliminates the need for a left and right animation. Instead it will flip the characters x-axis
void Flip()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
void OnGUI ()
{
GUI.Label (new Rect (500, 220, 150, 100), "playerGrounded: " + playerGrounded);
}
}
