Klasa silnika
VRService
*Ta zawartość została przetłumaczona przy użyciu narzędzi AI (w wersji beta) i może zawierać błędy. Aby wyświetlić tę stronę w języku angielskim, kliknij tutaj.
Podsumowanie
Właściwości
Metody
GetUserCFrame(type: Enum.UserCFrame):CFrame |
RequestNavigation(cframe: CFrame,inputUserCFrame: Enum.UserCFrame):() |
SetTouchpadMode(pad: Enum.VRTouchpad,mode: Enum.VRTouchpadMode):() |
Zdarzenia
NavigationRequested(cframe: CFrame,inputUserCFrame: Enum.UserCFrame):RBXScriptSignal |
UserCFrameChanged(type: Enum.UserCFrame,value: CFrame):RBXScriptSignal |
UserCFrameEnabled(type: Enum.UserCFrame,enabled: boolean):RBXScriptSignal |
Przykłady kodu
VRService
local VRService = game:GetService("VRService")
local part = workspace.Part
local handOffset = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
-- Uwzględnij skalę głowy
handOffset = handOffset.Rotation + handOffset.Position * workspace.CurrentCamera.HeadScale
part.CFrame = workspace.CurrentCamera.CFrame * handOffsetMateriały referencyjne dotyczące interfejsów API
Właściwości
GuiInputUserCFrame
Przykłady kodu
VRService.GuiInputUserCFrame
local VRService = game:GetService("VRService")
if VRService.VREnabled then
print(VRService.GuiInputUserCFrame.Name)
else
print("Nie wykryto urządzenia VR!")
endVREnabled
Przykłady kodu
Śledzenie głowy 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
-- Ustaw początkowy CFrame
head.CFrame = VRService:GetUserCFrame(Enum.UserCFrame.Head)
-- Śledź ruch zestawu VR i odzwierciedlaj go dla głowy postaci
VRService.UserCFrameChanged:Connect(TrackHead)
endMetody
GetTouchpadMode
Parametry
Zwroty
Przykłady kodu
VRService:GetTouchpadMode
local VRService = game:GetService("VRService")
-- Pobierz tryb dotykowy VRTouchpad.Left
VRService:GetTouchpadMode(Enum.VRTouchpad.Left)GetUserCFrame
Parametry
Zwroty
Przykłady kodu
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)
-- Uwaga na skalę głowy
handOffset = handOffset.Rotation + handOffset.Position * camera.HeadScale
part.CFrame = camera.CFrame * handOffsetGetUserCFrameEnabled
Parametry
Zwroty
Przykłady kodu
VRService:GetUserCFrameEnabled
local VRService = game:GetService("VRService")
local isEnabled = VRService:GetUserCFrameEnabled(Enum.UserCFrame.Head)
if isEnabled then
print("Urządzenie VR jest włączone!")
else
print("Urządzenie VR jest wyłączone!")
endRecenterUserHeadCFrame
VRService:RecenterUserHeadCFrame():()
Zwroty
()
Przykłady kodu
VRService:PrzesuńCFrameGłowyUżytkownika
local VRService = game:GetService("VRService")
VRService:RecenterUserHeadCFrame()Parametry
Zwroty
()
Przykłady kodu
VRService:RequestNavigation
local VRService = game:GetService("VRService")
local destination = workspace:FindFirstChild("NavigationDestination")
VRService:RequestNavigation(Enum.UserCFrame.Head, destination.CFrame)SetTouchpadMode
Parametry
Zwroty
()
Przykłady kodu
VRService:SetTouchpadMode
local VRService = game:GetService("VRService")
VRService:SetTouchpadMode(Enum.VRTouchpad.Left, Enum.VRTouchpadMode.Touch)Zdarzenia
Parametry
Przykłady kodu
VRService.NavigationRequested
local VRService = game:GetService("VRService")
VRService.NavigationRequested:Connect(function(cframe, inputUserCFrame)
print(inputUserCFrame.Name .. " wysłał żądanie z CFrame: " .. cframe)
end)TouchpadModeChanged
Parametry
Przykłady kodu
VRService.TouchpadModeChanged
local VRService = game:GetService("VRService")
VRService.TouchpadModeChanged:Connect(function(pad, mode)
print(pad.Name .. " Touchpad zmienił stan na: " .. mode.Name)
end)UserCFrameChanged
Parametry
Przykłady kodu
VRService.UserCFrameChanged
local VRService = game:GetService("VRService")
VRService.UserCFrameChanged:Connect(function(userCFrameType, cframeValue)
print(userCFrameType.Name .. " zmienione. Zaktualizowana ramka: " .. tostring(cframeValue))
end)UserCFrameEnabled
Parametry
Przykłady kodu
VRService.UserCFrameEnabled
local VRService = game:GetService("VRService")
VRService.UserCFrameEnabled:Connect(function(type, enabled)
if enabled then
print(type.Name .. " został włączony!")
else
print(type.Name .. " został wyłączony!")
end
end)