Raycast
2025/12/27
- Type
- Learning Resource
- Format
- Glossary Article
- Version
- General
- Subject Tags
- Created
- Updated
- 2026/02/16
- 2025/12/27
A raycast is a technique for detecting collisions between a straight line and an object. It's like firing a laser beam from a point in space and seeing if it hits anything.
In Godot, you can use raycasts to detect collisions in 2D and 3D games with the RayCast2D and RayCast3D nodes. You can control the direction and length of the ray with the nodes' target_position property.
If the ray intersects with another object, the raycast node tells you the position of the intersection point and the object it hit. You can also get the normal of the surface that the ray hits, that is, a vector perpendicular to the surface that tells you the direction the surface is facing.
Raycasts are used for many mechanics and features, including:
Don't stop here. Step-by-step tutorials are fun but they only take you so far.
Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.
Get help from peers and pros on GDQuest's Discord server!
20,000 membersJoin ServerThere are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!
Sponsor this library by learning gamedev with us onGDSchool
Learn MoreImprove and build on assets or suggest edits onGithub
Contributeshare this page and talk about GDQUest onRedditYoutubeTwitter…