Reference API Roblox

Engine API

Website

Related

Reference API Roblox

PhysicsService

This class is not creatable. Instances of this class cannot be created with Instance.new.
This class is a service. It is a singleton that may be acquired with GetService.
Tags: [NotCreatable, Service]

Member index 17

HistoryMember
557CollisionGroupContainsPart(name: string, part: BasePart): bool
573CollisionGroupSetCollidable(name1: string, name2: string, collidable: bool): null
462CollisionGroupsAreCollidable(name1: string, name2: string): bool
557CreateCollisionGroup(name: string): int
557GetCollisionGroupId(name: string): int
557GetCollisionGroupName(name: int): string
557GetCollisionGroups(): Array
462GetMaxCollisionGroups(): int
538GetRegisteredCollisionGroups(): Array
573IkSolve(part: BasePart, target: CFrame, translateStiffness: float, rotateStiffness: float): null
546IsCollisionGroupRegistered(name: string): bool
573LocalIkSolve(part: BasePart, target: CFrame, translateStiffness: float, rotateStiffness: float): null
573RegisterCollisionGroup(name: string): null
573RemoveCollisionGroup(name: string): null
573RenameCollisionGroup(from: string, to: string): null
573SetPartCollisionGroup(part: BasePart, name: string): null
573UnregisterCollisionGroup(name: string): null
inherited from Instance
553Archivable: bool
635Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
635Sandboxed: bool
616UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
641GetStyled(name: string): Variant
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
580IsPropertyModified(name: string): bool
573Remove(): null
576RemoveTag(tag: string): null
580ResetPropertyToDefault(name: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Description

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.

History 85

Members 17

CollisionGroupContainsPart

Parameters (2)
namestring
partBasePart
Returns (1)
bool

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.
This function is deprecated. It exists only for backward compatibility, and should not be used for new work. CollisionGroup should be used instead.

History 9

Tags: [Deprecated]

CollisionGroupSetCollidable

Parameters (3)
name1string
name2string
collidablebool
Returns (1)
null

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.

History 3

CollisionGroupsAreCollidable

Parameters (2)
name1string
name2string
Returns (1)
bool

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.

History 2

CreateCollisionGroup

Parameters (1)
namestring
Returns (1)
int

Creates a new collision group with the given name, and returns the ID of the created group.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work. RegisterCollisionGroup should be used instead.

History 8

Tags: [Deprecated]

GetCollisionGroupId

Parameters (1)
namestring
Returns (1)
int

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.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work. CollisionGroup should be used instead.

History 8

Tags: [Deprecated]

GetCollisionGroupName

Parameters (1)
nameint
Returns (1)
string

Returns the name of the collision group with the corresponding ID. This method will return nil if the group with the corresponding ID has not been named.

This function is deprecated. It exists only for backward compatibility, and should not be used for new work. CollisionGroup should be used instead.

History 8

Tags: [Deprecated]

GetCollisionGroups

Parameters (0)
No parameters.
Returns (1)
Array

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:

MemberTypeDescription
idintegerThe ID of the group.
maskintegerThe collision group's mask; only for internal use.
namestringThe name of the collision group.
This function is deprecated. It exists only for backward compatibility, and should not be used for new work. GetRegisteredCollisionGroups should be used instead.

History 8

Tags: [Deprecated]

GetMaxCollisionGroups

Parameters (0)
No parameters.
Returns (1)
int

Returns the maximum number of collision groups the engine supports. This value is currently 32.

History 2

GetRegisteredCollisionGroups

Parameters (0)
No parameters.
Returns (1)
Array

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:

MemberTypeDescription
maskintegerThe collision group's mask; only for internal use.
namestringName of the collision group.

History 1

IkSolve

Parameters (4)
partBasePart
targetCFrame
translateStiffnessfloat
rotateStiffnessfloat
Returns (1)
null

History 4

IsCollisionGroupRegistered

Parameters (1)
namestring
Returns (1)
bool

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().

History 1

LocalIkSolve

Parameters (4)
partBasePart
targetCFrame
translateStiffnessfloat
rotateStiffnessfloat
Returns (1)
null

History 4

RegisterCollisionGroup

Parameters (1)
namestring
Returns (1)
null

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.

History 2

RemoveCollisionGroup

Parameters (1)
namestring
Returns (1)
null

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.
This function is deprecated. It exists only for backward compatibility, and should not be used for new work. UnregisterCollisionGroup should be used instead.

History 9

Tags: [Deprecated]

RenameCollisionGroup

Parameters (2)
fromstring
tostring
Returns (1)
null

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.

History 3

SetPartCollisionGroup

Parameters (2)
partBasePart
namestring
Returns (1)
null

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 BasePart instance.
  • The specified group does not exist.
This function is deprecated. It exists only for backward compatibility, and should not be used for new work. CollisionGroup should be used instead.

History 10

Tags: [Deprecated]

UnregisterCollisionGroup

Parameters (1)
namestring
Returns (1)
null

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.

History 2

Settings