Raycast

2025/12/27

Type
Learning Resource
Format
Glossary Article
Version
General
Subject Tags
Code
Assets
All else
Copyright 2016-2026, GDQuest
Created
2026/02/16
Updated
2025/12/27

Raycast

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:

Become an Indie Gamedev with GDQuest!

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.

Nathan

Founder and teacher at GDQuest
  • Starter Kit
  • Learn Gamedev from Zero
Check out GDSchool

You're welcome in our little community

Get help from peers and pros on GDQuest's Discord server!

20,000 membersJoin Server

Contribute to GDQuest's Free Library

There are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!