c# Raycast and then checking tag

I’m willing to accept that this question has been asked a hundred times before, but all of the answers I’ve tried over the last hour or so haven’t worked.

Basically I have a Raycast which goes beneath my character in order to check if he’s touching the ground to enable him to jump again. I’ve since then added some trigger colliders to stuff to dampen velocity, but the raycast hits this trigger collider (which obviously I walk through not stand on) so it makes the jumping unusual. As such, I need to be able to get the raycast to ignore this. I’m trying to do this with tag. I have tagged the offending trigger collider “JumpStop”, and I have added an if statement to the raycast to check that the tag of the object raycasted != “JumpStop”.

It doesn’t work, and I’m pretty sure it’s because I’m not doing the raycast properly. Please help.

I have a variable declared at the start (GameObject hitInfo)

	if (Physics.Raycast (transform.position, Vector3.down, out hitInfo, raycastLength)) 
		if (hitInfo.collider.tag != "JumpStop") {
		jumping = false;

Is there something obviously wrong here?

I just recently read another answer that solved the problem for me. Essentially there is a menu option to make raycasts ignore triggers

Check here

From @OrangeLightning

Either use layers or you might simply want to go to:

Edit → Project Settings → Physics →
Raycasts Hit Trigger

And set that to false.

The right way to do a ray cast that ignores things is to put what you want the ray cast to hit in a different layer and then limit the cast to that layer.