Tunneling

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

Tunneling

Tunneling is when physics entities move fast enough that they jump through walls or collision areas. It's a common problem in game development.

Normally, the physics engine checks for collisions in each physics update using the object's final position. If the object moves too fast and collision shapes are small enough, it can pass through a wall without triggering a collision. One frame, the object is on one side of the wall, and the next frame, it's on the other side. For the physics engine, it never collided with the wall.

For most games and entities, this is not a problem. But it can be a big issue for fast-moving objects like bullets. For this reason, it's common to use ray-casts or shape-casts to detect collisions for fast-moving objects, which do not have the tunneling problem as they check for collisions along a projected line.

Continuous Collision Detection

Tunneling can also be solved with Continuous Collision Detection (CCD). This feature checks for collisions along the path of an object's movement rather than just at its final position. Under the hood, the feature may use ray-casting or shape-casting on top of your entity's collision shape.

CCD costs performance and isn't necessary in most cases, so it's usually off by default in game engines. We can enable it for specific physics bodies that need it. The feature is available in Godot for physics body nodes (not areas). You can enable it in code for a given body like this:

extends CharacterBody2D

func _ready():
    var resource_id := get_rid()
    PhysicsServer2D.body_set_continuous_collision_detection_mode(resource_id, PhysicsServer2D.CCD_MODE_CAST_RAY)
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!