World Root
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Tóm tắt
Phương Pháp
Thành viên kế thừa
26 thành viên kế thừa từ Model
4 thành viên kế thừa từ PVInstance
58 thành viên kế thừa từ Instance
6 thành viên kế thừa từ Object
Được kế thừa bởi
Tài Liệu Tham Khảo API
Phương Pháp
Are Parts Touching Others
Tham Số
partList:Instances |
| Giá Trị Mặc Định: 0.000199999995 |
Lợi Nhuận
Mẫu mã
Kiểm tra các phần chạm nhau
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)) -- Đúng
print(workspace:ArePartsTouchingOthers(partList, 0.999)) -- Đúng
print(workspace:ArePartsTouchingOthers(partList, 1)) -- SaiBlockcast
World Root: Blockcast(
Tham Số
| Giá Trị Mặc Định: RaycastParams{IgnoreWater=false, Margin=0, SizeGradient=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}} |
Lợi Nhuận
Mẫu mã
Chiếu Khối
local Workspace = game:GetService("Workspace")
local function castBlock()
-- Vị trí ban đầu và độ xoay của hình dạng khối chiếu
local originCFrame = CFrame.new(Vector3.new(0, 50, 0))
-- Kích thước của hình dạng khối chiếu
local size = Vector3.new(6, 3, 9)
-- Hướng mà khối được chiếu vào
local direction = -Vector3.yAxis
-- Khoảng cách tối đa của việc chiếu
local distance = 50
-- Chiếu khối và tạo một hình ảnh minh họa cho nó
local raycastResult = Workspace:Blockcast(originCFrame, size, direction * distance)
if raycastResult then
-- In ra tất cả các thuộc tính của RaycastResult nếu nó tồn tại
print(`Khối đã va chạm với: {raycastResult.Instance:GetFullName()}`)
print(`Vị trí va chạm: {raycastResult.Position}`)
print(`Khoảng cách giữa vị trí ban đầu của khối và kết quả: {raycastResult.Distance}`)
print(`Vector pháp tuyến của mặt đã va chạm: {raycastResult.Normal}`)
print(`Vật liệu bị va chạm: {raycastResult.Material.Name}`)
else
print("Không có gì bị va chạm")
end
end
-- Liên tục chiếu một khối mỗi 2 giây
while true do
castBlock()
task.wait(2)
endBulk Move To
Tham Số
partList:Instances |
| Giá Trị Mặc Định: FireAllEvents |
Lợi Nhuận
()
Collision Groups Are Collidable
Collision Group Set Collidable
Find Part On Ray
find Part On Ray
Find Part On Ray With Ignore List
Find Part On Ray With Whitelist
Find Parts In Region3
find Parts In Region3
Find Parts In Region3 With Ignore List
Find Parts In Region3 With White List
Get Part Bounds In Box
Tham Số
| Giá Trị Mặc Định: OverlapParams{MaxParts=0, Tolerance=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}} |
Lợi Nhuận
{BasePart}
Get Part Bounds In Radius
World Root: Get Part Bounds In Radius(
Tham Số
| Giá Trị Mặc Định: OverlapParams{MaxParts=0, Tolerance=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}} |
Lợi Nhuận
{BasePart}
Get Parts In Part
Tham Số
| Giá Trị Mặc Định: OverlapParams{MaxParts=0, Tolerance=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}} |
Lợi Nhuận
{BasePart}
IK Move To
World Root: IK Move To(
part:BasePart, target:CFrame, translate Stiffness:number, rotate Stiffness:number, collisions Mode:Enum.IKCollisionsMode
):()
Tham Số
| Giá Trị Mặc Định: 0.5 |
| Giá Trị Mặc Định: 0.5 |
| Giá Trị Mặc Định: OtherMechanismsAnchored |
Lợi Nhuận
()
Is Collision Group Registered
Is Region3 Empty
Is Region3 Empty With Ignore List
Raycast
Tham Số
| Giá Trị Mặc Định: RaycastParams{IgnoreWater=false, Margin=0, SizeGradient=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}} |
Lợi Nhuận
Mẫu mã
Chiếu tia
local Workspace = game:GetService("Workspace")
local function castRay()
-- Điểm gốc của tia
local originPosition = Vector3.new(0, 50, 0)
-- Hướng mà tia được chiếu vào
local direction = -Vector3.yAxis
-- Khoảng cách tối đa của tia
local distance = 50
-- Chiếu tia và tạo một hình ảnh minh họa cho nó
local raycastResult = Workspace:Raycast(originPosition, direction * distance)
if raycastResult then
-- In ra tất cả các thuộc tính của RaycastResult nếu nó tồn tại
print(`Ray đã va chạm với: {raycastResult.Instance:GetFullName()}`)
print(`Vị trí giao nhau: {raycastResult.Position}`)
print(`Khoảng cách giữa gốc tia và kết quả: {raycastResult.Distance}`)
print(`Vector pháp tuyến của mặt đã va chạm: {raycastResult.Normal}`)
print(`Vật liệu bị va chạm: {raycastResult.Material.Name}`)
else
print("Không có gì bị va chạm")
end
end
-- Liên tục chiếu tia mỗi 2 giây
while true do
castRay()
task.wait(2)
endRename Collision Group
Shapecast
World Root: Shapecast(
part:BasePart, direction:Vector3, params:RaycastParams, cframe Override:CFrame?, size Override:Vector3?
Tham Số
| Giá Trị Mặc Định: RaycastParams{IgnoreWater=false, Margin=0, SizeGradient=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}} |
| Giá Trị Mặc Định: nil |
| Giá Trị Mặc Định: nil |
Lợi Nhuận
Spherecast
World Root: Spherecast(
Tham Số
| Giá Trị Mặc Định: RaycastParams{IgnoreWater=false, Margin=0, SizeGradient=0, BruteForceAllSlow=false, RespectCanCollide=false, CollisionGroup=Default, FilterDescendantsInstances={}} |
Lợi Nhuận
Mẫu mã
Chiếu hình cầu
local Workspace = game:GetService("Workspace")
local function castSphere()
-- Vị trí ban đầu của hình cầu được chiếu
local originPosition = Vector3.new(0, 50, 0)
-- Bán kính của hình cầu được chiếu tính bằng studs
local radius = 10
-- Hướng mà hình cầu được chiếu vào
local direction = -Vector3.yAxis
-- Khoảng cách tối đa của việc chiếu
local distance = 50
-- Chiếu hình cầu và tạo một hình ảnh minh họa cho nó
local raycastResult = Workspace:Spherecast(originPosition, radius, direction * distance)
if raycastResult then
-- In ra tất cả các thuộc tính của RaycastResult nếu nó tồn tại
print(`Hình cầu va chạm với: {raycastResult.Instance:GetFullName()}`)
print(`Vị trí va chạm: {raycastResult.Position}`)
print(`Khoảng cách giữa vị trí ban đầu của hình cầu và kết quả: {raycastResult.Distance}`)
print(`Vector pháp tuyến của mặt đã va chạm: {raycastResult.Normal}`)
print(`Vật liệu bị va chạm: {raycastResult.Material.Name}`)
else
print("Không có gì bị va chạm")
end
end
-- Liên tục chiếu một hình cầu mỗi 2 giây
while true do
castSphere()
task.wait(2)
endStep Physics
Tham Số
parts:Instances Giá Trị Mặc Định: {} |
Lợi Nhuận
()
Mẫu mã
Bước Vật Lý
local RunService = game:GetService("RunService")
-- Mảng tùy chọn các phần để mô phỏng; nếu không, tất cả các phần sẽ được mô phỏng
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
-- Mô phỏng các phần trong không gian làm việc trong 5 giây, bước các phần một lần mỗi khung hình
simulateParts(5.0)