GearBlocks
The GearBlocks Lua scripting API
Static Public Member Functions | List of all members
SmashHammer.GearBlocks.Construction.PartColliderRegistry Class Reference

A registry of all part colliders in the scene. More...

Static Public Member Functions

static IPart GetPart (int colliderInstanceID)
 Retrieves a part from the instance ID of one of its colliders.
 

Detailed Description

A registry of all part colliders in the scene.

Member Function Documentation

◆ GetPart()

static IPart SmashHammer.GearBlocks.Construction.PartColliderRegistry.GetPart ( int  colliderInstanceID)
static

Retrieves a part from the instance ID of one of its colliders.

Parameters
colliderInstanceIDInstance ID of the collider to search with.
Returns
The found part, if any.

A collider ID is provided by a raycast hit query (see Physics), and can be used to get the part that was hit, for example:

if Physics.RayCast( Vector3.__new( 0, 10, 0 ), Vector3.Forward, 1000 ) then
local distance, position, normal, colliderInstanceID = Physics.QueryCastHit( 0 )
local part = PartColliderRegistry.GetPart( colliderInstanceID )
if part then
print( 'Part: ' .. part.FullDisplayName )
end
end
A registry of all part colliders in the scene.
Definition PartColliderRegistry.cs:12
static IPart GetPart(int colliderInstanceID)
Retrieves a part from the instance ID of one of its colliders.