Class
PhysicsService
NotCreatableServiceDeprecated
Service that provides methods for creating and managing collision groups,
which control whether sets of BaseParts collide with each
other.
Deprecated. This service has been deprecated in favor of per-world collision group
configuration through WorldRoot which should be used for collision
group management. Existing PhysicsService calls will forward to
Workspace.
PhysicsService primarily contains methods for working with collision
groups which define whether a set of parts may or may not collide with parts
in other collision groups. You can register a collision group through
RegisterCollisionGroup() and
assign parts to it by setting those parts'
CollisionGroup property to the name of the
collision group.
Creating, deleting, and modifying collision relationships between collision
groups is limited to server-side Scripts.
See Collision Filtering for usage details in Studio and within scripts.
Methods 15#
| CollisionGroupContainsPart | Returns whether the part is in the collision group.Deprecated |
| CollisionGroupsAreCollidable | Returns whether the two groups will collide.Deprecated |
| CollisionGroupSetCollidable | Sets the collision status between two groups.Deprecated |
| CreateCollisionGroup | Creates a new collision group with the given name, and returns the ID of the created group.Deprecated |
| GetCollisionGroupId | Returns the ID of the collision group with the specified name.Deprecated |
| GetCollisionGroupName | Returns the name of the group with the corresponding ID.Deprecated |
| GetCollisionGroups | Returns a table with info on all of the place's collision groups.Deprecated |
| GetMaxCollisionGroups | Returns the maximum number of collision groups.Deprecated |
| GetRegisteredCollisionGroups | Returns a table with info on all of the place's collision groups.Deprecated |
| IsCollisionGroupRegistered | Checks if a collision group is registered.Deprecated |
| RegisterCollisionGroup | Registers a new collision group with the given name.Deprecated |
| RemoveCollisionGroup | Removes the collision group with the given name.Deprecated |
| RenameCollisionGroup | Renames specified collision group.Deprecated |
| SetPartCollisionGroup | Sets the collision group of a part.Deprecated |
| UnregisterCollisionGroup | Unregisters the collision group for the given name.Deprecated |
CollisionGroupContainsPart(name: string, part: BasePart): boolean#
DeprecatedDeprecated
Deprecated. This method has been deprecated. It's recommended that you query a part's
collision group through its CollisionGroup
property.
Returns whether the specified part is in the specified collision group. This method will throw a runtime error in the following circumstances:
- The specified group does not exist.
- The specified part is not a
BasePart.
| Name | Type | Default | Description |
|---|---|---|---|
name | string | The name of the collision group to check. | |
part | BasePart | The BasePart to check for membership in the collision group. |
Returns
boolean—trueif the part belongs to the specified collision group,falseotherwise.
CollisionGroupsAreCollidable(name1: string, name2: string): boolean#
Deprecated
Deprecated. This method has been superseded by
WorldRoot:CollisionGroupsAreCollidable() which should be used for
all new work.
Returns whether the two specified collision groups will collide. This method will also return true if either of the groups are unregistered, as the default collision mask collides with all groups.
| Name | Type | Default | Description |
|---|---|---|---|
name1 | string | The name of the first collision group. | |
name2 | string | The name of the second collision group. |
Returns
boolean—trueif the two groups are set to collide,falseotherwise. Also returnstrueif either group is unregistered.
CollisionGroupSetCollidable(name1: string, name2: string, collidable: boolean): ()#
Deprecated
Deprecated. This method has been superseded by
WorldRoot:CollisionGroupSetCollidable() which should be used for
all new work.
Sets the collision status between two groups. This method will throw an
error if either of the groups is unregistered, so it's recommended that
you confirm each group's registration through
PhysicsService:IsCollisionGroupRegistered() before making this
call.
| Name | Type | Default | Description |
|---|---|---|---|
name1 | string | The name of the first collision group. | |
name2 | string | The name of the second collision group. | |
collidable | boolean | Whether the two groups should collide with each other. |
Returns
()
CreateCollisionGroup(name: string): int#
DeprecatedDeprecated
Deprecated. This method has been superseded by
RegisterCollisionGroup() which
should be used for all new work.
Creates a new collision group with the given name, and returns the ID of the created group.
| Name | Type | Default | Description |
|---|---|---|---|
name | string | The name of the new collision group to create. |
Returns
int— The integer ID assigned to the newly created collision group.
GetCollisionGroupId(name: string): int#
DeprecatedDeprecated
Deprecated. This method has been deprecated. It's recommended that you query collision
groups by name through a part's
CollisionGroup property.
This method returns the ID of the collision group with the specified name. It will throw an error if no group with the given name exists.
| Name | Type | Default | Description |
|---|---|---|---|
name | string | The name of the collision group being retrieved. |
Returns
int— The ID of the retrieved collision group, ornilif no such group exists.
GetCollisionGroupName(name: int): string#
DeprecatedDeprecated
Deprecated. This method has been deprecated. It's recommended that you query collision
groups by name through a part's
CollisionGroup property.
Returns the name of the collision group with the corresponding ID, or an
empty string if that ID (0–31) has not been assigned to a group. The
method throws an error if the ID is outside the valid range.
| Name | Type | Default | Description |
|---|---|---|---|
name | int | The integer ID of the collision group to look up. |
Returns
string— The name of the collision group with the given ID, or an empty string if the ID has not been assigned to a group.
GetCollisionGroups(): Array#
DeprecatedDeprecated
Deprecated. This method has been superseded by
GetRegisteredCollisionGroups()
which should be used for all new work.
Returns a table with info on all of the place's collision groups. Each value in the returned table is itself a table containing three members:
| Member | Type | Description |
|---|---|---|
| id | integer | The ID of the group. |
| mask | integer | The collision group's mask; only for internal use. |
| name | string | The name of the collision group. |
Returns
Array— An array of tables, each containingname(string),id(integer), andmask(integer) fields for a registered collision group.
GetMaxCollisionGroups(): int#
Deprecated
Deprecated. This method has been superseded by
WorldRoot:GetMaxCollisionGroups() which should be used for all new
work.
Returns the maximum number of collision groups the engine supports. This value is currently 32.
Returns
int— The maximum number of collision groups supported, currently 32.
GetRegisteredCollisionGroups(): Array#
Deprecated
Deprecated. This method has been superseded by
WorldRoot:GetRegisteredCollisionGroups() which should be used for
all new work.
Returns a table with info on all of the place's collision groups. Each value in the returned table is itself a table and containing two members:
| Member | Type | Description |
|---|---|---|
| mask | integer | The collision group's mask; only for internal use. |
| name | string | Name of the collision group. |
Returns
Array— An array of tables, each containingname(string) andmask(integer) fields for a registered collision group.
IsCollisionGroupRegistered(name: string): boolean#
Deprecated
Deprecated. This method has been superseded by
WorldRoot:IsCollisionGroupRegistered() which should be used for
all new work.
Checks if a collision group is registered. It's recommended that you call
this method before calling methods that throw errors for unregistered
collision groups, such as
PhysicsService:CollisionGroupSetCollidable().
| Name | Type | Default | Description |
|---|---|---|---|
name | string | The name of the collision group to check. |
Returns
boolean—trueif a collision group with the given name is registered,falseotherwise.
RegisterCollisionGroup(name: string): ()#
Deprecated
Deprecated. This method has been superseded by
WorldRoot:RegisterCollisionGroup() which should be used for all
new work.
Registers a new collision group with the given name. The name cannot be
"Default".
Note that this method has a slight performance overhead based on the
number of BaseParts in the workspace, so it's recommended
that you register all collision groups at edit time through the Studio
editor and call
UnregisterCollisionGroup()
and RenameCollisionGroup()
as infrequently as possible.
| Name | Type | Default | Description |
|---|---|---|---|
name | string | The name of the collision group to register. |
Returns
()
RemoveCollisionGroup(name: string): ()#
DeprecatedDeprecated
Deprecated. This method has been superseded by
UnregisterCollisionGroup()
which should be used for all new work.
Removes the collision group with the given name. If an invalid name is
provided, this method will not do anything, although if the reserved name
"Default" is provided, it will throw an error. If there are any parts in
the collision group when it is removed, these parts will still maintain
the same collision group ID. The physical behavior of parts in a removed
group is undefined, so it is recommended to move any parts in a removed
group to another group. This method will throw a runtime error in the
following circumstances:
- The name
"Default"is provided. - The method is called from a client.
| Name | Type | Default | Description |
|---|---|---|---|
name | string | The name of the collision group to remove. |
Returns
()
RenameCollisionGroup(from: string, to: string): ()#
Deprecated
Deprecated. This method has been superseded by
WorldRoot:RenameCollisionGroup() which should be used for all new
work.
Renames the specified registered collision group, but does not rename
the CollisionGroup property of parts that
utilize the group. The first argument of this method is the name of the
group to rename, the second argument is the new name for the group. If the
specified group does not exist, this method will not do anything. The
naming conventions for the new name follow the same rules as if the group
was being created with
RegisterCollisionGroup().
This method will throw a runtime error in the following circumstances:
- Invalid or empty name provided for either argument.
- The method is called from a client.
Note that this method has a slight performance overhead based on the
number of BaseParts in the workspace, so it's recommended
that you register all collision groups at edit time through the Studio
editor and rename
them as infrequently as possible.
| Name | Type | Default | Description |
|---|---|---|---|
from | string | The current name of the collision group to rename. | |
to | string | The new name for the collision group. |
Returns
()
SetPartCollisionGroup(part: BasePart, name: string): ()#
DeprecatedDeprecated
Deprecated. This method has been deprecated. It's recommended that you set a part's
collision group by name through its
CollisionGroup property.
This method sets the collision group of the specified part to the group
with the specified name. It is equivalent to setting the
BasePart.CollisionGroupId, although calling this method is the
recommended approach.
This method will throw a runtime error in the following circumstances:
- The part parameter is not a
BasePartinstance. - The specified group does not exist.
| Name | Type | Default | Description |
|---|---|---|---|
part | BasePart | The part being set. | |
name | string | The name of collision group that the part's collision group is being set to. |
Returns
()
UnregisterCollisionGroup(name: string): ()#
Deprecated
Deprecated. This method has been superseded by
WorldRoot:UnregisterCollisionGroup() which should be used for all
new work.
Unregisters the collision group for the given name, with the following behaviors:
- If an invalid name is provided, the method will not do anything.
- If the reserved name
"Default"is provided or if the method is called from a client, it will throw an error. - If there are any parts in the collision group when it is removed, those
parts will still maintain the same collision group name. The physical
behavior of parts in a removed group is undefined, so it's recommended
to move any parts in a removed group to another group, such as the
"Default"group.
Note that this method has a slight performance overhead based on the
number of BaseParts in the workspace, so it's recommended
that you register all collision groups at edit time through the Studio
editor and call this
method as infrequently as possible.
| Name | Type | Default | Description |
|---|---|---|---|
name | string | The name of the collision group to unregister. |
Returns
()
Inherited members#
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild