PhysicsService

PhysicsService : Instance

Overview

The PhysicsService class is a server-side service that provides tools for managing collision groups, allowing developers to control whether specific sets of parts can collide with each other. It enables advanced collision filtering beyond the basic CanCollide property, making it ideal for creating complex interactions, such as player-to-player collisions, NPC interactions, or custom physics systems.

Description

The PhysicsService class is used to define and manage collision groups, which are sets of parts categorized by a shared name. By assigning parts to these groups and specifying their collision relationships, developers can control how objects interact in the game world. This service is particularly useful for optimizing physics performance and implementing specific gameplay mechanics.

Properties

Methods

CollisionGroupSetCollidable

Sets whether two collision groups are collidable with each other.

Parameters

string Group1

string Group2

bool bCollidable

Return

void

Code Samples

CollisionGroupsAreCollidable

Checks if two collision groups are collidable.

Parameters

string Group1

string Group2

Return

bool

Code Samples

GetMaxCollisionGroups

maximum number of collision groups available.

Parameters

Return

Value

Code Samples

local PhysicsService = game:GetService("PhysicsService")

print(PhysicsService:GetMaxCollisionGroups())

GetRegisteredCollisionGroups

Returns list of registered collision groups

Parameters

Return

Value

Code Samples

//NotWork//

IsCollisionGroupRegistered

Checks if a specified collision group is registered in the system.

Parameters

string Group

Return

bool

Code Samples

//NotWork//

RegisterCollisionGroup

Register a collision group by specifying a name.

Parameters

string Group

Return

void

Code Samples

//NotWork//

RenameCollisionGroup

Rename the name of the collision group.

Parameters

string FromGroup

string ToGroup

Return

void

Code Samples

UnregisterCollisionGroup

Unregister the collision group with the specified name.

Parameters

string Group

Return

void

Code Samples

Events