Collision layers and masks

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

Collision layers and masks

In Godot, collision layers and masks are properties available to all physics nodes that filter which nodes can interact with each other. They are a very efficient way to filter physics interactions performance-wise.

While the two properties are called layers and masks, you can think of them as more of a grouping or tagging system but just for physics. Physics layers control what physics groups a node is part of, and physics masks control what physics groups a node detects.

For example, if you have a player character and a wall, you might want the player to collide with the wall but not with other players.

You can achieve this by setting the player's collision layer to 1 and the collision mask to 2. Then, you can set the wall's collision layer to 2 and give it no collision mask (because the wall itself doesn't need to detect anything; only the player needs to detect the wall and stop when touching it).

This way, the player will detect the wall because the player's collision mask matches the wall's collision layer. The player won't detect other players because its collision mask doesn't match the other players' collision layer.

Why are these called layers and masks?

Under the hood, Godot uses binary operations to handle collision layers and masks. The physics layers and masks are encoded as whole numbers in the computer's memory. The numbers are then compared using binary operations to determine if two nodes should interact with each other. These are very efficient operations that compare the individual 0s and 1s of the binary representation of the numbers, maximizing filtering performance.

This is probably where the term mask comes from, as the binary operations are often called bitmasking operations. The term layer is likely used because it's a common term in 3D modeling and game development to refer to groups of objects.

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!