Engine-klasse
VRService
*Deze inhoud is vertaald met behulp van AI (bèta) en kan fouten bevatten. Klik hier om deze pagina in het Engels te bekijken.
Samenvatting
Eigenschappen
Methoden
GetUserCFrame(type: Enum.UserCFrame):CFrame |
RequestNavigation(cframe: CFrame,inputUserCFrame: Enum.UserCFrame):() |
SetTouchpadMode(pad: Enum.VRTouchpad,mode: Enum.VRTouchpadMode):() |
Evenementen
NavigationRequested(cframe: CFrame,inputUserCFrame: Enum.UserCFrame):RBXScriptSignal |
UserCFrameChanged(type: Enum.UserCFrame,value: CFrame):RBXScriptSignal |
UserCFrameEnabled(type: Enum.UserCFrame,enabled: boolean):RBXScriptSignal |
Codevoorbeelden
VRService
local VRService = game:GetService("VRService")
local part = workspace.Part
local handOffset = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
-- Houd rekening met de hoofdschaling
handOffset = handOffset.Rotation + handOffset.Position * workspace.CurrentCamera.HeadScale
part.CFrame = workspace.CurrentCamera.CFrame * handOffsetAPI-referentie
Eigenschappen
GuiInputUserCFrame
Codevoorbeelden
VRService.GuiInputUserCFrame
local VRService = game:GetService("VRService")
if VRService.VREnabled then
print(VRService.GuiInputUserCFrame.Name)
else
print("Geen VR-apparaat gedetecteerd!")
endVREnabled
Codevoorbeelden
VR Hoofd Tracking
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
-- Stel de initiële CFrame in
head.CFrame = VRService:GetUserCFrame(Enum.UserCFrame.Head)
-- Volg de beweging van de VR-headset en spiegel deze voor het hoofd van het karakter
VRService.UserCFrameChanged:Connect(TrackHead)
endMethoden
GetTouchpadMode
Parameters
Teruggaves
Codevoorbeelden
VRService:GetTouchpadMode
local VRService = game:GetService("VRService")
VRService:GetTouchpadMode(Enum.VRTouchpad.Left)GetUserCFrame
Parameters
Teruggaves
Codevoorbeelden
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)
-- Houd rekening met headscale
handOffset = handOffset.Rotation + handOffset.Position * camera.HeadScale
part.CFrame = camera.CFrame * handOffsetGetUserCFrameEnabled
Parameters
Teruggaves
Codevoorbeelden
VRService:GetUserCFrameEnabled
local VRService = game:GetService("VRService")
local isEnabled = VRService:GetUserCFrameEnabled(Enum.UserCFrame.Head)
if isEnabled then
print("VR-apparaat is ingeschakeld!")
else
print("VR-apparaat is gedeactiveerd!")
endRecenterUserHeadCFrame
VRService:RecenterUserHeadCFrame():()
Teruggaves
()
Codevoorbeelden
VRService:RecenterUserHeadCFrame
local VRService = game:GetService("VRService")
VRService:RecenterUserHeadCFrame()Parameters
Teruggaves
()
Codevoorbeelden
VRService:RequestNavigation
local VRService = game:GetService("VRService")
local destination = workspace:FindFirstChild("NavigationDestination")
VRService:RequestNavigation(Enum.UserCFrame.Head, destination.CFrame)SetTouchpadMode
Parameters
Teruggaves
()
Codevoorbeelden
VRService:SetTouchpadMode
local VRService = game:GetService("VRService")
VRService:SetTouchpadMode(Enum.VRTouchpad.Left, Enum.VRTouchpadMode.Touch)Evenementen
Parameters
Codevoorbeelden
VRService.NavigationRequested
local VRService = game:GetService("VRService")
VRService.NavigationRequested:Connect(function(cframe, inputUserCFrame)
print(inputUserCFrame.Name .. " heeft een aanvraag gedaan met CFrame: " .. cframe)
end)TouchpadModeChanged
Parameters
Codevoorbeelden
VRService.TouchpadModeChanged
local VRService = game:GetService("VRService")
VRService.TouchpadModeChanged:Connect(function(pad, mode)
print(pad.Name .. " Touchpad veranderd naar status: " .. mode.Name)
end)UserCFrameChanged
Parameters
Codevoorbeelden
VRService.UserCFrameChanged
local VRService = game:GetService("VRService")
VRService.UserCFrameChanged:Connect(function(userCFrameType, cframeValue)
print(userCFrameType.Name .. " is veranderd. Geüpdatete Frame: " .. tostring(cframeValue))
end)UserCFrameEnabled
Parameters
Codevoorbeelden
VRService.UserCFrameEnabled
local VRService = game:GetService("VRService")
VRService.UserCFrameEnabled:Connect(function(type, enabled)
if enabled then
print(type.Name .. " is ingeschakeld!")
else
print(type.Name .. " is uitgeschakeld!")
end
end)