WorldRoot

사용되지 않는 항목 표시

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

만들 수 없음

이 기본 클래스는 3D 공간 쿼리 및 시뮬레이션을 처리하기 위한 API를 제공합니다. WorkspaceWorldModel와 같은.

요약

속성

속성Model에서 상속되었습니다
  • 플러그인 보안
    병렬 읽기

    인스턴스 스트림이 활성화된 경험에 대한 모델의 세부 정보 수준을 설정합니다.

  • Class.Model|Models 인스턴스 스트림이 활성화된 경우 모델 스트림 동작을 제어합니다.

  • 병렬 읽기

    명시적으로 설정되지 않은 경우 Model 또는 nil입니다.

  • 복제되지 않음
    스크립팅할 수 없음
    병렬 읽기

    모델 주위의 피벗을 조정하는 편집기 전용 속성입니다. 이 속성을 설정하면 피벗이 있는 것처럼 Model/ScaleTo 가 호출됩니다.

  • 복제되지 않음
    병렬 읽기

    Class.Model의 피벗이 어디에 있는지 결정합니다. 이 피벗은 아님 이 세트에 있는 Model.PrimaryPart입니다.

속성PVInstance에서 상속되었습니다

메서드

메서드Model에서 상속되었습니다
  • AddPersistentPlayer(playerInstance : Player):void

    이 모델을 지정된 플레이어에게 영구적으로 유지하도록 합니다. Model.ModelStreamingMode 는 추가를 결과로 변경하는 동안 PersistentPerPlayer 에 설정해야 합니다.

  • 모델의 모든 부분이 포함된 볼륨의 설명을 반환합니다.

  • Class.Model의 모든 Model를 포함하는 가장 작은 바인딩 상자의 크기를 반환합니다. Model.PrimaryPart가 설정된 경우 1>Class.Model1>와 함께.

  • 이 모델 개체가 지속되는 모든 Player 개체를 반환합니다. 동작은 이 메서드가 Script 또는 LocalScript에서 호출되는지에 따라 변경됩니다.

  • 새로 생성된 모델의 경우 기본적으로 1이 되지만 Model/ScaleTo 를 통해 크기를 조정하면 변경됩니다.

  • MoveTo(position : Vector3):void

    이동 하는 PrimaryPart 를 지정된 위치로. 주 부품이 지정되지 않은 경우 모델의 기본 부품이 사용됩니다.

  • RemovePersistentPlayer(playerInstance : Player):void

    이 모델은 더 이상 지속되지 않습니다. Model.ModelStreamingMode 는 제거된 플레이어의 동작에 대해 PersistentPerPlayer 로 설정해야 합니다.

  • ScaleTo(newScaleFactor : number):void

    모델의 크기 조정 요소를 설정하고, 모든 후손 인스턴스의 크기를 조정하여 크기 요소가 모델의 초기 크기와 위치에 비례하여 크기 요소가 1인 경우 모델의 크기를 조정합니다.

  • TranslateBy(delta : Vector3):void

    Class.Model을 주어진 Vector3 오프셋으로 이동하여 모델의 방향을 유지합니다. 다른 BasePart 또는 1>Class.Terrain1>이 이미 새로운 위치에 있으면 4>Class.Model4>는 해당 오프셋을

메서드PVInstance에서 상속되었습니다

속성

메서드

ArePartsTouchingOthers

ArePartsTouchingOthers 는 적어도 하나의 주어진 BasePart 가 다른 부품을 터치하고 있는 경우 트루로 반환합니다. 두 부품은 거리 임계값 내에 있으면 overlapIgnored 로 간주됩니다.

부품이 제공되지 않으면 false가 반환됩니다.

매개 변수

partList: Instances

목록에 있는 부품 중 하나가 목록에 없는 부품을 터치하는지 여부를 확인하는 부품 목록입니다.A list of parts checks to see if any parts in the list are touching any parts not in the list.

overlapIgnored: number

부품이 터치되기 전에 공간 중복 임계값입니다.

기본값: 0.000199999995

반환

Class.Part|parts 중 하나를 partList 에 만지는 경우에만 참이 됩니다. Class.Part|parts 가 다른 부품을 만지고 있지 않은 경우에는 참이 되지 않습니다.

코드 샘플

The code block below demonstrates how to use WorldRoot:ArePartsTouchingOthers() to check if parts in a list are touching any parts in the workspace not in the list.

First the script creates two square parts that overlap 1 stud, Part1 and Part2. Then, it prints the value returned by ArePartsTouchingOthers() when Part1 is passed in partList at three different overlap values: 0, 0.999, and 1. The first two times ArePartsTouchingOthers() is called return false because the overlap values are less than the distance that Part1 and Part2 overlap. The third call returns true because the overlap value is equal to the distance that the parts overlap.

Checking for Touching Parts

local part1 = Instance.new("Part")
part1.Name = "Part1"
part1.Anchored = true
part1.Transparency = 0.5
part1.Color = Color3.fromRGB(185, 100, 38)
part1.Size = Vector3.new(2, 2, 2)
part1.Position = Vector3.new(0, 4, 0)
part1.Parent = workspace
local part2 = Instance.new("Part")
part2.Name = "Part2"
part2.Anchored = true
part2.Transparency = 0.5
part2.Color = Color3.fromRGB(200, 10, 0)
part2.Size = Vector3.new(2, 2, 2)
part2.Position = Vector3.new(0, 5, 0)
part2.Parent = workspace
local partList = { part1 }
print(workspace:ArePartsTouchingOthers(partList, 0)) -- True
print(workspace:ArePartsTouchingOthers(partList, 0.999)) -- True
print(workspace:ArePartsTouchingOthers(partList, 1)) -- False

Blockcast

병렬 쓰기

지정된 방향으로 블록 모양을 캐스트하고 첫 번째 충돌을 BasePart 또는 Terrain 셀로 반환합니다. 이는 WorldRoot:Raycast() 가 직선 빔을 사용하여 충돌을 찾지만 3D 모양을 사용합니다와 유사합니다.

Class.WorldRoot:GetPartsInPart() 와는 달리, 이 메서드는 모양을 처음 BaseParts 에 교차하는 개체를 감지하지 않습니다.

히트가 감지되면 RaycastResult 가 히트 정보를 포함하는 반환됩니다. Distance 속성은 모양이 히트를 찾기 위해 여행해야 하는 거리를 나타내며, Position 속성은 히트가 발생하는 경우 발

이 메서드는 잘못 된 CFrame 크기 또는 방향 입력을 통해 오류가 발생 했습니다.

매개 변수

cframe: CFrame

캐스트 블록 모양의 초기 위치 및 회전.

size: Vector3

캐스트 블록 모양의 크기를 스터드 단위로 나타냅니다. 최대 크기는 512 스터드입니다.

direction: Vector3

셰이펙스트의 방향, 셰이펙스트가 여행할 수 있는 최대 거리를 나타내는 크기. 최대 거리는 1024 스터드입니다.

기본값: "RaycastParams{IgnoreWater=false, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}"

반환

셰이펙스트 작업의 결과, 또는 nil 을 포함하거나 BasePart 또는 Terrain 셀이 명중되지 않았습니다.

코드 샘플

Casts a block and returns the first collision with a BasePart or Terrain. Prints the properties of the RaycastResult if a result was hit.

Blockcasting

local Workspace = game:GetService("Workspace")
local function castBlock()
-- The initial position and rotation of the cast block shape
local originCFrame = CFrame.new(Vector3.new(0, 50, 0))
-- The size of the cast block shape
local size = Vector3.new(6, 3, 9)
-- The direction the block is cast in
local direction = -Vector3.yAxis
-- The maximum distance of the cast
local distance = 50
-- Cast the block and create a visualization of it
local raycastResult = Workspace:Blockcast(originCFrame, size, direction * distance)
if raycastResult then
-- Print all properties of the RaycastResult if it exists
print(`Block intersected with: {raycastResult.Instance:GetFullName()}`)
print(`Intersection position: {raycastResult.Position}`)
print(`Distance between block's initial position and result: {raycastResult.Distance}`)
print(`The normal vector of the intersected face: {raycastResult.Normal}`)
print(`Material hit: {raycastResult.Material.Name}`)
else
print("Nothing was hit")
end
end
-- Continually cast a block every 2 seconds
while true do
castBlock()
task.wait(2)
end

BulkMoveTo

void

이 함수는 기본 속성 설정을 호출하지 않고 데이터 타입 프레임워크 또는 프레임에 테이블을 이동하는 기능을 제공합니다. 이를 통해 부품의 큰 수를 쉽게 이동할 수 있습니다. 이 함수는 부품 크기를 줄이기 위해 별도의 속성 집합

세 번째 인수를 사용하여 이동 작업을 더 최적화할 수 있습니다. 기본적으로, 각 부

코드에서 부품 이동이 병목 현상인 경우에만 이 함수를 사용해야 합니다. 개별 부품과 용접된 모델의 속성을 단순히 설정하면 대부분의 경우 충분히 빠릅니다.

매개 변수

partList: Instances
cframeList: Array
기본값: "FireAllEvents"

반환

void

GetPartBoundsInBox

Instances
병렬 쓰기

Class.WorldRoot:GetPartBoundsInBox() 는 주어진 센터( Datatype.CFrame ), 크기(CFrame), 설명된 상자(0> Class.WorldRoot:GetPartBoundsInBox()0>), 기타 부품(WorldRoot:GetPartBoundsInBox()3> 등을 포함한 부품 배열을 반환합니다.

지정된 부품의 바인딩 상자 크기가 실제 부품의 실제 부품 크기가 아닌 경우 이 공간 쿼리 메서드는 부품을 둘러싸는 셀의 수를 셀당 효율적으로 고려하므로 중요할 수 있습니다. 이 메서드에서 부품을 필터

이 메서드는 OverlapParams 개체를 사용하여 공간 쿼리의 재사용 가능한 부분을 설명하는데, 포함 또는 제외 목록, 쿼리할 부품의 최대 수, 쿼리가 충돌 그룹을 사용하도록 하는

매개 변수

cframe: CFrame

쿼리할 상자 볼륨의 중심 위치.

size: Vector3

쿼리할 주어진 상자 볼륨의 크기입니다.

overlapParams: OverlapParams

공간 쿼리 매개 변수의 재사용 가능한 부분을 포함합니다.

기본값: "OverlapParams{MaxParts=0, Tolerance=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}"

반환

Instances

공간 쿼리에 일치하는 BaseParts 배열.

GetPartBoundsInRadius

Instances
병렬 쓰기

Class.WorldRoot:GetPartBoundsInRadius() 는 주어진 센터( Datatype.Vector3 ), 라디우스(Vector3), 범위(0> number0>), 부품(WorldRoot:GetPartBoundsInRadius()3> 를 반환합니다.

지정된 부품의 바인딩 상자 크기가 실제 부품의 실제 부품 크기가 아닌 경우 이 공간 쿼리 메서드는 부품을 둘러싸는 셀의 수를 셀당 효율적으로 고려하므로 중요할 수 있습니다. 이 메서드에서 부품을 필터

이 메서드는 OverlapParams 개체를 사용하여 공간 쿼리의 재사용 가능한 부분을 설명하는데, 포함 또는 제외 목록, 쿼리할 부품의 최대 수, 쿼리가 충돌 그룹을 사용하도록 하는

매개 변수

position: Vector3

지정된 구형 볼륨의 중심 위치를 쿼리할 위치입니다.

radius: number

지정된 구 볼륨의 반경을 쿼리할 수 있습니다.

overlapParams: OverlapParams

공간 쿼리 매개 변수의 재사용 가능한 부분을 포함합니다.

기본값: "OverlapParams{MaxParts=0, Tolerance=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}"

반환

Instances

공간 쿼리에 일치하는 BaseParts 배열.

GetPartsInPart

Instances
병렬 쓰기

WorldRoot:GetPartsInPart() 는 지정된 부품과 공유된 공간을 가진 부품의 배열을 반환합니다(이는 쿼리된 부품과 동일한 WorldRoot 에 있어야 함). 이 메서드는 BasePart:GetTouchingParts() 대신 사용될 수 있습니다.

지정된 부품에 대해 전체 기하학 충돌 확인사용하여 부품의 정확한 볼륨을 계산하는 이 공간 쿼리 메서드는 정확한 부품 을 찾을 수 없습니다. 예를 들어, 콘콘/홀로 부

이 메서드는 OverlapParams 개체를 사용하여 공간 쿼리의 재사용 가능한 부분을 설명하는데, 포함 또는 제외 목록, 쿼리할 부품의 최대 수, 쿼리가 충돌 그룹을 사용하도록 하는

매개 변수

part: BasePart

다른 부품과 대비하여 검사해야 하는 부품의 볼륨입니다.

overlapParams: OverlapParams

공간 쿼리 매개 변수의 재사용 가능한 부분을 포함합니다.

기본값: "OverlapParams{MaxParts=0, Tolerance=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}"

반환

Instances

공간 쿼리에 일치하는 BaseParts 배열.

IKMoveTo

void
플러그인 보안

이 함수는 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역 역

강도 번호는 0에서 1 사이의 숫자입니다. 강도는 대상 CFrame의 위치에 부품의 위치를 일치시키는 정도를 지정합니다. 강도는 대상 CFrame의 위치에 부품의 회전을 일치시키는 정도를 지정합니다. 강도는 대상 CFrame의 위치에 부품의 회전을 일치시킬 수 있습니다. 예를 들어:

  • 번역 강도 및 회전 강도가 모두 1과 같으면 부품이 잠긴 CFrame으로 정확히 이동됩니다.
  • 번역 강도 및 회전 강도가 모두 0.5인 경우 부품은 정확히 대상 CFrame으로 이동하려고 시도하지만 물리적 제약 사항으로 인해 길을 벗어날 수 있습니다.
  • 번역 강도 및 회전 강도가 모두 0인 경우 대상 CFrame은 무시되고 물리적 제약 사항은 위치에 있는 개체에 해결됩니다.

매개 변수

part: BasePart

이동 중인 부품.

target: CFrame

지정된 부품을 이동할 위치.

translateStiffness: number

위치 일치 대상 CFrame 의 대상 위치에 부품의 위치를 얼마나 공격적으로 일치시킬지 지정하는 숫자.

기본값: 0.5
rotateStiffness: number

0에서 1 사이의 숫자로 특정 부품의 회전 부품에 대해 얼마나 공격적으로 일치할지 지정합니다. CFrame .

기본값: 0.5
collisionsMode: Enum.IKCollisionsMode

물리적 해상도에 의해 효과를 받는 개체를 지정할 수 있습니다.

기본값: "OtherMechanismsAnchored"

반환

void
병렬 쓰기

원본, 방향 및 선택적 Datatype.RaycastParams 를 사용하여 광선을 캐스트합니다. 이 작업이 적격한 RaycastParams 또는 BasePart

향상된 길이(길이) 벡터의 길이(길이)가 중요한 경우 개체/지형이 길의 길이 이상으로 멀리 있으면 테스트되지 않습니다. 레이 구성 요소를 만들기 위해 CFrame 를 사용하는 경우 <

이 메서드는 Ray 개체를 사용하지 않지만 원래 및 방향 구성 요소는 Ray.Origin 및 1> Datatype.Ray.Direction1> 에서 대출할 수 있습니다.

매개 변수

origin: Vector3

광선의 원래 위치.

direction: Vector3

레이의 방향 벡터입니다. 이 벡터의 길이는 부품/지형이 길이보다 멀리 떨어져 있기 때문에 테스트되지 않습니다.

raycastParams: RaycastParams

레이캐스트 작업에서 적중 가능성을 지정하는 개체입니다. 제공되지 않으면 모든 부품이 고려되고 Terrain 물이 무시됩니다.

기본값: "RaycastParams{IgnoreWater=false, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}"

반환

광선 캐스트 작업의 결과, 또는 nil 을 포함하거나 BasePart 또는 Terrain 셀이 타격되지 않았습니다.

코드 샘플

Casts a ray and returns the first collision with a BasePart or Terrain. Prints the properties of the RaycastResult if a result was hit.

Raycasting

local Workspace = game:GetService("Workspace")
local function castRay()
-- The origin point of the ray
local originPosition = Vector3.new(0, 50, 0)
-- The direction the ray is cast in
local direction = -Vector3.yAxis
-- The maximum distance of the ray
local distance = 50
-- Cast the ray and create a visualization of it
local raycastResult = Workspace:Raycast(originPosition, direction * distance)
if raycastResult then
-- Print all properties of the RaycastResult if it exists
print(`Ray intersected with: {raycastResult.Instance:GetFullName()}`)
print(`Intersection position: {raycastResult.Position}`)
print(`Distance between ray origin and result: {raycastResult.Distance}`)
print(`The normal vector of the intersected face: {raycastResult.Normal}`)
print(`Material hit: {raycastResult.Material.Name}`)
else
print("Nothing was hit")
end
end
-- Continually cast a ray every 2 seconds
while true do
castRay()
task.wait(2)
end

Shapecast

매개 변수

part: BasePart
direction: Vector3
기본값: "RaycastParams{IgnoreWater=false, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}"

반환

Spherecast

병렬 쓰기

지정된 방향으로 구형 모양을 캐스트하고 첫 번째 충돌을 BasePart 또는 Terrain 셀로 첫 번째 충돌을 반환합니다. 이는 WorldRoot:Raycast() 를 사용하여 직선 빔을 캐스트하는 방식과 유사합니다.

Class.WorldRoot:GetPartsInPart() 와는 달리, 이 메서드는 모양을 처음 BaseParts 에 교차하는 개체를 감지하지 않습니다.

히트가 감지되면 RaycastResult 가 히트 정보를 포함하는 반환됩니다. Distance 속성은 모양이 히트를 찾기 위해 여행해야 하는 거리를 나타내며, Position 속성은 히트가 발생하는 경우 발

이 메서드는 잘못된 반경이나 방향 입력을 통과하면 오류를 발생시킵니다.

매개 변수

position: Vector3

캐스트 구형 모양의 초기 위치.

radius: number

스터드 단위의 캐스트 구형 모양의 반경. 최대 반경은 256 스터드입니다.

direction: Vector3

셰이펙스트의 방향, 셰이펙스트가 여행할 수 있는 최대 거리를 나타내는 크기. 최대 거리는 1024 스터드입니다.

기본값: "RaycastParams{IgnoreWater=false, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}}"

반환

셰이펙스트 작업의 결과, 또는 nil 을 포함하거나 BasePart 또는 Terrain 셀이 명중되지 않았습니다.

코드 샘플

Casts a sphere and returns the first collision with a BasePart or Terrain. Prints the properties of the RaycastResult if a result was hit.

Spherecasting

local Workspace = game:GetService("Workspace")
local function castSphere()
-- The initial position of the cast spherical shape
local originPosition = Vector3.new(0, 50, 0)
-- The radius of the cast spherical shape in studs
local radius = 10
-- The direction the sphere is cast in
local direction = -Vector3.yAxis
-- The maximum distance of the cast
local distance = 50
-- Cast the sphere and create a visualization of it
local raycastResult = Workspace:Spherecast(originPosition, radius, direction * distance)
if raycastResult then
-- Print all properties of the RaycastResult if it exists
print(`Sphere intersected with: {raycastResult.Instance:GetFullName()}`)
print(`Intersection position: {raycastResult.Position}`)
print(`Distance between sphere's initial position and result: {raycastResult.Distance}`)
print(`The normal vector of the intersected face: {raycastResult.Normal}`)
print(`Material hit: {raycastResult.Material.Name}`)
else
print("Nothing was hit")
end
end
-- Continually cast a sphere every 2 seconds
while true do
castSphere()
task.wait(2)
end

StepPhysics

void
플러그인 보안

지정된 시간 증가량 및 옵션 세트의 BasePart

매개 변수

dt: number

시뮬레이션할 시간의 양. 이 인수는 음수여야 합니다. 값이 더 크면 이 함수의 런타임이 증가합니다.

parts: Instances

시뮬레이션할 부품 옵션 배열. 이 집합에는 BasePart 유형의 인스턴스만 포함되어야 합니다. 다른 형식은 무시됩니다.

기본값: "{}"

반환

void

코드 샘플

Simulates the parts in the workspace for a fixed period of time by calling the StepPhysics function once per frame until a specified time has elaspsed.

StepPhysics

local RunService = game:GetService("RunService")
-- Optional array of parts to simulate; otherwise all parts will be simulated
local partsToSimulate = {
workspace.Part
}
local function simulateParts(duration)
local time = 0.0
local stepJob
stepJob = RunService.RenderStepped:Connect(function(dt)
if time + dt > duration then
dt = duration - time
end
workspace:StepPhysics(dt, partsToSimulate)
time = time + dt
if time >= duration then
stepJob:Disconnect()
end
end)
end
-- Simulate workspace parts for 5 seconds, stepping the parts once per frame
simulateParts(5.0)

이벤트