Collision Filtering

Collision filtering defines which physical objects collide with others. You can filter collisions by assigning BaseParts to collision groups or on a part-to-part basis with NoCollisionConstraint instances. One useful application of filtering is disabling character collisions.

Collision Groups

Collision groups let you assign BaseParts to dedicated groups and specify whether or not they collide with those in other groups. Objects within non-colliding groups pass through or ignore each other completely.

In the video above, the spinning objects are in different collision groups such that they collide with objects of another color but not with objects of their own color

Collision Groups Editor

You can easily set up collision groups through Studio's Collision Groups Editor, accessible by clicking the Collision Groups button in the Model tab.

The editor functions in either Table View, which favors docking to the top or bottom of Studio, or a narrow List View which favors docking to the left or right side.

Creating Groups

The editor opens with one Default collision group. All BaseParts automatically belong to this default group unless assigned to another group, meaning that they will collide with all other objects in the Default group.

To create a new collision group:

  1. Click the Add Group button along the top of the editor panel.

  2. Enter a new group name like Cubes and press Enter. The new group appears in both the left column and upper row of Table View, or in both columns of List View.

  3. Repeat the process if necessary, choosing a unique and descriptive name for each group. Note that you can change a group's name during development by clicking in its field, or by selecting it and clicking the rename button.

Assigning Objects to Groups

Once you've created at least one custom collision group, you can assign objects.

  1. Select one or more BaseParts that qualify as part of a collision group.

  2. Assign them to the group by clicking the button for its row.

    In the Properties window, the new group is reflected under CollisionGroup.

Configuring Groups

Under default configuration, objects in all groups collide with each other. To prevent objects in one group from colliding with objects in another group, uncheck the box in the respective row/column.

In the following example, objects in the Cubes group will not collide with each other or with objects in the Doors group.

Script Configuration

Collision groups can also be configured through scripting as follows:

  1. Register empty collision groups via PhysicsService:RegisterCollisionGroup().

  2. Assign objects to a group by setting their CollisionGroup property to the string name of the collision group, for example "Cubes".

  3. Specify whether objects in groups collide by calling CollisionGroupSetCollidable(), providing the two collision groups and a boolean true (collidable) or false (non-collidable). If objects in the same group should or shouldn't collide with each other, use that group name for both the first and second parameters.

    Collision Group Setup

    local PhysicsService = game:GetService("PhysicsService")
    local cubes = "Cubes"
    local doors = "Doors"
    -- Register two collision groups
    -- Assign an object to each group
    workspace.Cube1.CollisionGroup = cubes
    workspace.Door1.CollisionGroup = doors
    -- Set cubes to be non-collidable with other cubes
    PhysicsService:CollisionGroupSetCollidable(cubes, cubes, false)
    -- Set cubes to be non-collidable with doors
    PhysicsService:CollisionGroupSetCollidable(cubes, doors, false)

Part-to-Part Filtering

To prevent collisions between two specific parts without setting up collision groups, such as between a vehicle's wheel and its chassis, consider the No Collision constraint. Advantages include:

  • Configuration scripts are not required, so you can easily create and share models with customized collision filtering.
  • Connected parts will not collide with each other, but they can still collide with other objects.

Disabling Character Collisions

Roblox characters collide with each other by default. This can lead to interesting gameplay, such as characters jumping on top of each other to reach specific areas. If this behavior is undesirable, you can prevent it through the following Script in ServerScriptService.

Script - Disable Character Collisions

local PhysicsService = game:GetService("PhysicsService")
local Players = game:GetService("Players")
PhysicsService:CollisionGroupSetCollidable("Characters", "Characters", false)
local function onDescendantAdded(descendant)
-- Set collision group for any part descendant
if descendant:IsA("BasePart") then
descendant.CollisionGroup = "Characters"
local function onCharacterAdded(character)
-- Process existing and new descendants for physics setup
for _, descendant in pairs(character:GetDescendants()) do
-- Detect when the player's character is added