I'm new here and can't understand why the Raycast won't hit anything even if the drawn Ray should totally hit...

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {
public float speed;
public float jumpHeigth;
private Rigidbody2D rb;
RaycastHit hit;
Ray touchingGroundRay;

void Start () {
	rb = GetComponent<Rigidbody2D> ();
	touchingGroundRay = new Ray (transform.position, Vector3.down);
}

void Update () {
	Debug.DrawRay (transform.position, Vector3.down * 1.5f);
	if (Input.GetKeyDown (KeyCode.Space) && Physics.Raycast (touchingGroundRay,out hit, 1.5f)) {
				rb.velocity = new Vector2 (rb.velocity.x, jumpHeigth);
	}
	if(Input.GetKey(KeyCode.D)) {
		rb.velocity = new Vector2 (speed, rb.velocity.y);
	}
	if(Input.GetKey(KeyCode.A)) {
		rb.velocity = new Vector2 (-speed, rb.velocity.y);
	}
}

}

I got it figured out myself. I used Physics.Raycast instead of Physics2D.Raycast sorry for the Question :slight_smile: