เรียนรู้
Engine Class
VRService
ไม่สามารถสร้าง
บริการ

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


ตัวอย่างโค้ด
บริการ VR
local VRService = game:GetService("VRService")
local part = workspace.Part
local handOffset = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
-- คำนึงถึงขนาดหัว
handOffset = handOffset.Rotation + handOffset.Position * workspace.CurrentCamera.HeadScale
part.CFrame = workspace.CurrentCamera.CFrame * handOffset

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
AutomaticScaling
อ่านพร้อมๆ กัน
ความสามารถ: Input
VRService.AutomaticScaling:Enum.VRScaling

AvatarGestures
อ่านพร้อมๆ กัน
ความสามารถ: Input
VRService.AvatarGestures:boolean

ControllerModels
อ่านพร้อมๆ กัน
ความสามารถ: Input
VRService.ControllerModels:Enum.VRControllerModelMode

FadeOutViewOnCollision
อ่านพร้อมๆ กัน
ความสามารถ: Input
VRService.FadeOutViewOnCollision:boolean

GuiInputUserCFrame
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: Input
VRService.GuiInputUserCFrame:Enum.UserCFrame
ตัวอย่างโค้ด
VRService.GuiInputUserCFrame
local VRService = game:GetService("VRService")
if VRService.VREnabled then
print(VRService.GuiInputUserCFrame.Name)
else
print("ไม่พบอุปกรณ์ VR!")
end

LaserPointer
อ่านพร้อมๆ กัน
ความสามารถ: Input
VRService.LaserPointer:Enum.VRLaserPointerMode

ThirdPersonFollowCamEnabled
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: Input
VRService.ThirdPersonFollowCamEnabled:boolean

VREnabled
อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน
ความสามารถ: Input
VRService.VREnabled:boolean
ตัวอย่างโค้ด
ติดตามหัว VR
local VRService = game:GetService("VRService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.CharacterAdded:Wait()
local head = character:WaitForChild("Head")
local function TrackHead(inputType, value)
if inputType == Enum.UserCFrame.Head then
head.CFrame = value
end
end
if VRService.VREnabled then
-- ตั้งค่า CFrame เริ่มต้น
head.CFrame = VRService:GetUserCFrame(Enum.UserCFrame.Head)
-- ติดตามการเคลื่อนไหวเฮดเซ็ต VR และสะท้อนให้กับหัวของตัวละคร
VRService.UserCFrameChanged:Connect(TrackHead)
end

วิธีการ
GetTouchpadMode
ความสามารถ: Input
VRService:GetTouchpadMode(pad:Enum.VRTouchpad):Enum.VRTouchpadMode
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
โหมดสัมผัสของ VRService
local VRService = game:GetService("VRService")
-- ดึงโหมดสัมผัส
VRService:GetTouchpadMode(Enum.VRTouchpad.Left)

GetUserCFrame
ความสามารถ: Input
VRService:GetUserCFrame(type:Enum.UserCFrame):CFrame
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
VRService:GetUserCFrame
local Workspace = game:GetService("Workspace")
local VRService = game:GetService("VRService")
local camera = Workspace.CurrentCamera
local part = script.Parent.Part
local handOffset = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
-- คำนึงถึงหัวสเกล
handOffset = handOffset.Rotation + handOffset.Position * camera.HeadScale
part.CFrame = camera.CFrame * handOffset

GetUserCFrameEnabled
ความสามารถ: Input
VRService:GetUserCFrameEnabled(type:Enum.UserCFrame):boolean
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
VRService:GetUserCFrameEnabled
local VRService = game:GetService("VRService")
local isEnabled = VRService:GetUserCFrameEnabled(Enum.UserCFrame.Head)
if isEnabled then
print("อุปกรณ์ VR ถูกเปิดใช้งานแล้ว!")
else
print("อุปกรณ์ VR ถูกปิดใช้งานแล้ว!")
end

RecenterUserHeadCFrame
ความสามารถ: Input
VRService:RecenterUserHeadCFrame():()
ส่งค่ากลับ
()
ตัวอย่างโค้ด
VRService:RecenterUserHeadCFrame
local VRService = game:GetService("VRService")
-- เรียกใช้ฟังก์ชันเพื่อตั้งตำแหน่งหัว
VRService:RecenterUserHeadCFrame()

RequestNavigation
ความสามารถ: Input
VRService:RequestNavigation(
cframe:CFrame, inputUserCFrame:Enum.UserCFrame
):()
พารามิเตอร์
cframe:CFrame
inputUserCFrame:Enum.UserCFrame
ส่งค่ากลับ
()
ตัวอย่างโค้ด
VRService:RequestNavigation
local VRService = game:GetService("VRService")
local destination = workspace:FindFirstChild("NavigationDestination")
VRService:RequestNavigation(Enum.UserCFrame.Head, destination.CFrame)

SetTouchpadMode
ความสามารถ: Input
VRService:SetTouchpadMode(
):()
พารามิเตอร์
ส่งค่ากลับ
()
ตัวอย่างโค้ด
โหมดการสัมผัสของ VRService
local VRService = game:GetService("VRService")
-- ตั้งค่าโหมดสัมผัสของ VRTouchpad.Left เป็น Touch
VRService:SetTouchpadMode(Enum.VRTouchpad.Left, Enum.VRTouchpadMode.Touch)

เหตุการณ์
NavigationRequested
ความสามารถ: Input
VRService.NavigationRequested(
cframe:CFrame, inputUserCFrame:Enum.UserCFrame
พารามิเตอร์
cframe:CFrame
inputUserCFrame:Enum.UserCFrame
ตัวอย่างโค้ด
VRService.NavigationRequested
local VRService = game:GetService("VRService")
VRService.NavigationRequested:Connect(function(cframe, inputUserCFrame)
print(inputUserCFrame.Name .. " ทำการร้องขอด้วย CFrame: " .. cframe)
end)

TouchpadModeChanged
ความสามารถ: Input
VRService.TouchpadModeChanged(
พารามิเตอร์
ตัวอย่างโค้ด
VRService.TouchpadModeChanged
local VRService = game:GetService("VRService")
VRService.TouchpadModeChanged:Connect(function(pad, mode)
print(pad.Name .. " Touchpad เปลี่ยนเป็นสถานะ: " .. mode.Name)
end)

UserCFrameChanged
ความสามารถ: Input
VRService.UserCFrameChanged(
พารามิเตอร์
value:CFrame
ตัวอย่างโค้ด
VRService.UserCFrameChanged
local VRService = game:GetService("VRService")
VRService.UserCFrameChanged:Connect(function(userCFrameType, cframeValue)
print(userCFrameType.Name .. " เปลี่ยนแปลงแล้ว. อัพเดตเฟรม: " .. tostring(cframeValue))
end)

UserCFrameEnabled
ความสามารถ: Input
VRService.UserCFrameEnabled(
type:Enum.UserCFrame, enabled:boolean
พารามิเตอร์
enabled:boolean
ตัวอย่างโค้ด
VRService.UserCFrameEnabled
local VRService = game:GetService("VRService")
VRService.UserCFrameEnabled:Connect(function(type, enabled)
if enabled then
print(type.Name .. " ถูกเปิดใช้งาน!")
else
print(type.Name .. " ถูกปิดใช้งาน!")
end
end)

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ