Controlling collisions, sometimes referred to as collision filtering, defines which physical objects can collide with others.
Collision groups let you place objects in dedicated groups and control whether they can collide or not collide with objects in other groups. Objects within non-colliding groups will simply pass through each other as shown with these green balls.
To set up collision groups in Studio:
Click the Collision Groups button () within the Advanced section of the Model tab.
In the Collision Groups Editor, click the small Add Group field in the lower area of the window. Type in a new group name like Obstacles, then press Enter/Return. Notice that the new group is added to both the left column and top row.
Repeat this process and add a third group named GreenObjects.
Select one or more objects in your place that would qualify as obstacles, then add them to the Obstacles collision group by clicking the button for its row.
Similarly, select one or more objects in your place that would qualify as green objects, then add them to the GreenObjects group by clicking its button.
At this point, all objects will collide with all other objects (default behavior). To prevent objects in the GreenObjects group from colliding with objects in the Obstacles group, uncheck the box in the respective row/column.
- If desired, create additional collision groups, add objects to them, and check/uncheck the appropriate boxes to control collision filtering throughout the place.
Collision groups can also be configured through scripting as follows:
- Create two empty collision groups via
- Once a group is created, objects can be added to it with
PhysicsService/SetPartCollisionGroup|PhysicsService:SetPartCollisionGroup(). This function requires the object to add and the string name of the collision group.
- To control whether objects in the GreenObjects group collide with objects in the Obstacles group, call
PhysicsService/CollisionGroupSetCollidable|PhysicsService:CollisionGroupSetCollidable(), providing the two collision groups and a boolean
Collision Group Notes/Limitations
- Objects can only belong to one collision group at a time. If you put them in a new group, they will be removed from their current group.
- Only objects with
BasePart/CanCollide|CanCollideenabled are affected by this system. If
BasePart/CanCollide|CanCollideis disabled, the object will not collide under any circumstances.
- The "Default" group cannot be removed.
- Each Roblox place supports up to 32 collision groups.
If you need to prevent specific part-to-part collisions, like stopping the wheel of a car from scraping against the car’s body, the
NoCollisionConstraint object is more convenient than setting up collision groups. Advantages include:
NoCollisionConstraintlets you create and share models with customized collision filtering. While you could still achieve filtering through collision groups, it would require adding a configuration script which executes when the game runs.
Connected parts will not collide with each other, but they can still collide with other objects.
NoCollisionConstraintis through the Create menu in the Constraints section of the Model tab. Similar to other constraints, this tool will act differently based on how many parts are selected when the tool is activated.
- If no parts are selected when the tool is activated, the next two parts that are clicked will be connected.
- If one part is selected when the tool is activated, the next part that is clicked will be connected to the selected part.
- If two parts are selected when the tool is activated, those two parts will be connected.
NoCollisionConstraint can also be added through scripting by creating a new instance and assigning its
NoCollisionConstraint/Part1|Part1 properties to the appropriate two parts.