Can't get my Player grounded

Hi. I can’t get my player grounded with this script. Any advice?

using UnityEngine;

using System.Collections;

public class Movement2D : MonoBehaviour {

	//Controls Player Movement
	public float movementSpeed = 5.0f;

	//Controls Player Jump
	private int jumpHeight = 500;
	public bool isGrounded = true;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		//Control PLayer Left Movement
	if (Input.GetKey ("left") || Input.GetKey ("a")) {
						transform.position -= Vector3.right * movementSpeed * Time.deltaTime;
		
		}
		//Control PLayer Right Movement
	if (Input.GetKey ("right") || Input.GetKey ("d")) {
			transform.position += Vector3.right * movementSpeed * Time.deltaTime;

	    }

		if ((Input.GetButtonDown ("Jump") || Input.GetKey ("w")) && isGrounded) {
						Jump ();
			Debug.Log ("hoppar");
				}


	}
	void Jump () {
		if (!isGrounded) {
						return;
				}
		isGrounded = false;
		rigidbody2D.AddForce (new Vector2 (0, jumpHeight));
}

	void FixedUpdate(){
		isGrounded = Physics.Raycast (transform.position, -Vector3.up, .5f);

}
}

the physics.raycast is sent from the transform.position point on your object that the Movement2D script is placed upon. Now normally this is from the center point of your 2D or 3D object. So if your object is greater than or equal to .5 units then your raycast will never hit anything as it will only go .5 units and stay within the player’s collision box.

What you can do is create an empty game object and place it on the feet of your character and parent it to your gameobject. Then call the raycast from that point by caching the transformation of your empty gameobject in your movement script and using its transform.position as the origin of your raycast.