Topic was automatically imported from the old Question2Answer platform.
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
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.