Godot 4 - How To Know if Your Raycasts are Hitting Anything

Автор - Thomas Yanuziello ссылка - От автора: You’ve added a ray cast node to your game but you’re not sure if it’s actually hitting anything or not. From the menu bar, open the Debug menu, and toggle on Visible Collision Shapes. Then run the game again. You’ll not only be able to see all of your game’s collision shapes rendered while the game is playing, But also ray casts will be drawn as arrows which change colour when they are hitting something. When Fierce Tooth approaches the ledge, the ray cast arrow turns blue since it is no longer colliding with the ground, telling the shark to turn around. You can also see exactly where dynamic ray casts are pointing, and whether or not they are being occluded by terrain or other obstacles.