Can't get Raycast2D to work and can't get any proper information

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Diegoteman

I’m rather new to Godot. I was trying to make a raycast that would check whether you had a wall on your back to allow you to walljump, kind of like in super metroid. Problem is, I’ve been trying to use Raycast2D for a while now and it just won’t work and I’m not sure why
onready var raycast = $WalljumpRay
func _physics_process(delta):
print(raycast.is_colliding())
This always returns false as seen in this image

Even while absurdly long, it never returns “true”, not even when including its parent in the collision tab. These are the settings

Please help me because I am going insane

:bust_in_silhouette: Reply From: a_world_of_madness

At least in the included screenshot the raycast node is disabled (the top toggle in the inspector). From the docs:

RayCast2D calculates intersection every physics frame (see Node), and the result is cached so it can be used later until the next frame

is_colliding will only return the cached result, so in your case it won’t return anything, since the cast was never done.
You need to either enable the automatic updating or run raycast.force_raycast_update() to manually do the raycast when you need the info.

:bust_in_silhouette: Reply From: jgodfrey

See that Enabled checkbox in the inspector for the Raycast2D node? It needs to be checked… :slight_smile:

Can’t believe I missed that lmao. Thanks a lot :slight_smile:

Diegoteman | 2022-10-29 11:40