I’m making a 2D platformer and my script uses raycasts to stop infinite jumping and for some reason the raycast stays inside the character instead of being outside of it which stops it from checking if I can jump.
My guess is that you’re casting the ray from the center of your character. If your character has a collider on it, then the ray will hit that collider and stop.
If that’s the case, there are a couple of things you can do:
1 - You can tell the raycast to ignore the collision layer of your character.
2 - Move the raycast origin from the center of the character (i.e. transform.position) to slightly outside of its collider (transform.position + (collider size / 2) + 0.01).
IMO, the first solution is a bit cleaner as collisions can only be trusted to a certain extent