VRService

사용되지 않는 항목 표시

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

만들 수 없음
서비스

VRService 는 Roblox와 가상 현실(VR) 사이의 상호 작용을 처리합니다. 그것의 메서드, 속성 및 이벤트는 최상의 경험을 제공하기 위해 사용자에게 최상의 경험을 제공하는 데 도움이 됩니다.

VR 장치에 대한 경험 게시에 대한 자세한 내용은 VR 가이드라인을 참조하십시오.

코드 샘플

The following example demonstrates how to get the Enum.UserCFrame of the left controller and place a part at that point in real world space. The CFrame of the controller changes whenever the device moves, so you should update the necessary parts whenever VRService.UserCFrameChanged fires.

VRService

local VRService = game:GetService("VRService")
local part = workspace.Part
local handOffset = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
-- Account for headscale
handOffset = handOffset.Rotation + handOffset.Position * workspace.CurrentCamera.HeadScale
part.CFrame = workspace.CurrentCamera.CFrame * handOffset

요약

속성

메서드

이벤트

속성

AutomaticScaling

병렬 읽기

Class.Camera.HeadScale 을 설정하면 Camera.HeadScale 세계의 크기를 조정하여 아바타의 관점에서 세계의 크기를 볼 수 있습니다. 작은 아바타를 가진 플레이어는 주변의 개체를 더 크게 인식합니다.

AvatarGestures

병렬 읽기

설정되면 VR 플레이어는 컨트롤러와 헤드셋을 사용하여 손과 머리를 애니메이션화할 수 있습니다.

이 속성은 서버에서 설정해야 합니다.

병렬 읽기

FadeOutViewOnCollision

병렬 읽기

진실로 되면 VR 플레이어의 뷰가 진실로 검은색으로 옅어지고 머리가 물체와 충돌할 때 VR 뷰가 검은색으로 표시됩니다. 이 속성은 플레이어가 VR에서 벽을 통과할 수 없게 합니다. 기본값은 진실로입니다.

GuiInputUserCFrame

복제되지 않음
병렬 읽기

이 속성은 VR에서 입력을 처리하는 VR 헤드셋의 책임을 설명합니다. 예를 인스턴스, VR 헤드셋이 책임을 지는 경우 이 속성의 값은 Enum.UserCFrame 가 됩니다.

Roblox가 VR 기기를 감지하는지 여부를 확인하려면 VREnabled 속성을 확인하십시오.

코드 샘플

This example checks if Roblox detects a VR device. If a VR device is detected, this prints the name of the UserCFrame responsible for VR input. If not, this example prints "No VR device detected!".

VRService.GuiInputUserCFrame

local VRService = game:GetService("VRService")
if VRService.VREnabled then
print(VRService.GuiInputUserCFrame.Name)
else
print("No VR device detected!")
end
병렬 읽기

ThirdPersonFollowCamEnabled

읽기 전용
복제되지 않음
병렬 읽기

VREnabled

읽기 전용
복제되지 않음
병렬 읽기

이 속성은 사용자가 가상 현실(VR) 기기사용하는지 여부를 설명합니다.

VR 장치가 활성화되면 위치 및 이동을 VR 장치를 통해 상호 작용할 수 있습니다. 이 메서드는 UserInputService:GetUserCFrame() 를 사용하여 상호 작용하거나 UserInputService.UserCFrameChanged 이벤트를 사용하여 반응할 수 있습니다.


local UserInputService = game:GetService("UserInputService")
local isUsingVR = UserInputService.VREnabled
if isUsingVR then
print("User is using a VR headset!")
else
print("User is not using a VR headset!")
end

이 속성은 LocalScript에서만 사용할 수 있습니다.

또 보기

코드 샘플

This example demonstrates how to implement a head tracking script that mirrors the movement of a virtual reality (VR) headset (the user's actual head) to their in-game character's head.

The example first check if the user is using a VR device by checking the value of the VREnabled() property. This example only works if the user is using a VR headset.

To determine the initial CFrame of the character's head, the code sample calls GetUserCFrame() and passes Enum.UserCFrame.Head as the argument.

To update the head's CFrame whenever the user's VR headset moves, the example connects the VRService.UserCFrameChanged event to the TrackHead() function. When the event fires to indicate that a VR device moved, TrackHead() checks if the headset moved. If the headset moved, the function updates the CFrame of the character's head to the CFrame value provided as an argument.

As the UserCFrame enum also tracks VR left and right hand devices, the concept of VR device tracking can be expanded to other character bodyparts.

In order for the example to work as expected, it must be placed in a LocalScript.

VR Head 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
-- Set the initial CFrame
head.CFrame = VRService:GetUserCFrame(Enum.UserCFrame.Head)
-- Track VR headset movement and mirror for character's head
VRService.UserCFrameChanged:Connect(TrackHead)
end

메서드

GetTouchpadMode

이 메서드는 Enum.VRTouchpadMode 를 반환하여 지정된 Enum.VRTouchpad 의 모드를 나타냅니다. 반환된 모드는 사용자가 게임을 플레이하는 방식에 대해 터치패드와 상호 작용하는 방법을 나타냅니다.

이 기능은 여러 UserInputService VR 메서드 및 이벤트와 함께 사용할 수도 있습니다.

이 메서드는 LocalScript에서만 작동합니다.

매개 변수

지정된 VRTouchpad .


반환

지정된 VRTouchpad의 모드.

코드 샘플

This example retrieves and prints the name of the user's current VRTouchpad.Left touchpad mode.

VRService:GetTouchpadMode

local VRService = game:GetService("VRService")
VRService:GetTouchpadMode(Enum.VRTouchpad.Left)

GetUserCFrame

이 메서드는 실제 세계 공간의 지점에서 특정 가상 현실(VR) 장치의 위치 및 방향을 설명하는 CFrame를 반환합니다. 이 메서드는 게임에 VR 호환성을 구현하는 데 사용됩니다. 이 메서드는 VR 장치의 연결된 기기대한 이동을 추적하는 데 사용됩니다.

이 메서드를 사용하면 사용자의 인게임 캐릭터를 연결된 VR 기기위치와 일치하도록 재정렬하는 등의 기능을 구현할 수 있습니다. 이 작업은 사용자의 인게임 캐릭터에 대한 CFrame를 변경하여 지정된 VR 장치의 CFrame</

VRService 또한 연결된 VR 장치의 UserCFrameChanged 이벤트를 자동으로 발생시키며, 연결된 VR 장치의 CFrame 이 변경되면 자동으로 발생하므로 이 경우 0>Class.LocalScript0> 에 사용됩니다.

이 메서드는 LocalScript에서만 작동합니다.

매개 변수

지정된 UserCFrame .


반환

코드 샘플

This example positions a part at the player's left hand, assuming Camera.HeadLocked = true

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)
-- Account for headscale
handOffset = handOffset.Rotation + handOffset.Position * camera.HeadScale
part.CFrame = camera.CFrame * handOffset

GetUserCFrameEnabled

이 메서드는 지정된 Enum.UserCFrame 가상 현실 장치(VR)가 사용 가능하도록 하는 경우에 트루를 반환합니다. 이를 사용하여 지정된 VR 기기, 예를 들어 Enum.UserCFrame.Head ,가 사용자의 게임에 연결되어 있는지 여부를 결정할 수 있습니다.

이 기능은 여러 UserInputService VR 메서드 및 이벤트와 함께 사용할 수도 있습니다.

이 메서드는 LocalScript에서만 작동합니다.

매개 변수

지정된 VR 기기유형입니다.


반환

지정된 VR 장치가 활성화되었는지 여부를 나타내는 부울(true).

코드 샘플

This example indicates whether the UserCFrame.Head VR device is enabled or disabled for the user. If the device is enabled, this prints "VR device is enabled!". If the device is disabled, this prints "VR device is disabled!".

VRService:GetUserCFrameEnabled

local VRService = game:GetService("VRService")
local isEnabled = VRService:GetUserCFrameEnabled(Enum.UserCFrame.Head)
if isEnabled then
print("VR device is enabled!")
else
print("VR device is disabled!")
end

RecenterUserHeadCFrame

void

이 메서드는 사용자의 머리의 CFrame을 현재 VR 헤드셋의 위치로 다시 센터화합니다. 이 메서드는 사용자의 게임 내 머리가 VR 헤드셋의 위치에 따라 위치를 조정하도록 합니다.

이 동작은 UserInputService:RecenterUserHeadCFrame() 와 동일합니다.

이 메서드는 LocalScript에서만 작동합니다.


반환

void

코드 샘플

This example fires the function to recenter the CFrame of the user's head to the current location of the VR headset being worn by the user.

VRService:RecenterUserHeadCFrame

local VRService = game:GetService("VRService")
VRService:RecenterUserHeadCFrame()

RequestNavigation

void

이 메서드는 시각화기 파라볼에 대한 원본으로 지정된 CFrame 을 사용하여 탐색을 요청합니다. 이 메서드는 가상 현실(VR)을 게임에 통합하기 위해 사용자의 VR 장치에서 탐색 경로를 시각화하는 수단을 제공하여 게임에 통합할 수 있습니다.

VRService 에는 유사한 이벤트, NavigationRequested, 이를 감지하는 데 사용됩니다. 이 방법은 여러 UserInputService VR 메서드 및 이벤트와 함께 사용할 수도 있습니다.

이 메서드는 LocalScript에서만 작동합니다.

매개 변수

cframe: CFrame

지정된 CFrame 좌표.

inputUserCFrame: Enum.UserCFrame

탐색을 요청하는 VR 장치.


반환

void

코드 샘플

This example requests navigation from the user's UserCFrame.Head coordinates to the CFrame coordinates of a Part named NavigationDestination.

Note: In order for this to work, a Part named NavigationDestination must exist in the game's Workspace.

VRService:RequestNavigation

local VRService = game:GetService("VRService")
local destination = workspace:FindFirstChild("NavigationDestination")
VRService:RequestNavigation(Enum.UserCFrame.Head, destination.CFrame)

SetTouchpadMode

void

이 메서드는 지정된 Enum.VRTouchpad의 모드를 지정된 Enum.VRTouchpadMode로 설정합니다. 이 메서드를 사용하여 사용자가 터치 패드를 사용하여 게임과 상호 작용하도록 사용자의 가상 현실(VR) 터치 패드 모드를 변경할 수 있습니다.

이 기능은 여러 UserInputService VR 메서드 및 이벤트와 함께 사용할 수도 있습니다.

이 메서드는 LocalScript에서만 작동합니다.

매개 변수

지정한 VRTouchpad 모드를 설정하려고 합니다.

지정한 VRTouchpad 에 설정하려는 모드입니다.


반환

void

코드 샘플

This example sets the user's VRTouchpad.Left touchpad mode to TouchMode.Touch. This means that the left touchpad is treated as ButtonB.

VRService:SetTouchpadMode

local VRService = game:GetService("VRService")
VRService:SetTouchpadMode(Enum.VRTouchpad.Left, Enum.VRTouchpadMode.Touch)

이벤트

이 이벤트는 특정 VRService 에서 특정 Enum.UserCFrame VR 기기대해 탐색을 요청할 때 발생합니다. 이 이벤트는 CFrame 좌표와 지정된 2>Enum.UserCFrame2> 가 장치에 요청하는 탐색을 나타내는 데 사용됩니다

이 이벤트는 UserInputService 서비스 이벤트 및 메서드와 함께 사용할 수 있습니다.

이 이벤트는 로컬에서 발생하므로 LocalScript 에만 사용할 수 있습니다.

매개 변수

cframe: CFrame

요청한 CFrame 좌표.

inputUserCFrame: Enum.UserCFrame

요청된 탐색에 대한 VR 장치를 나타냅니다.


코드 샘플

This example prints the name of the UserCFrame VR device making the request, and the CFrame coordinates passed.

VRService.NavigationRequested

local VRService = game:GetService("VRService")
VRService.TouchpadModeChanged:Connect(function(cframe, inputUserCFrame)
print(inputUserCFrame.Name .. " made request with CFrame: " .. cframe)
end)

TouchpadModeChanged

이 이벤트는 Enum.VRTouchpadMode 의 Enum.VRTouch 이 연결된 경우 발생합니다. 이 이벤트를 사용하여 사용자 클라이언트를 통해 연결된 VR 터치패드의 상태를 추적할 수 있습니다.

이 이벤트는 UserInputService 서비스 이벤트 및 메서드와 함께 사용할 수 있습니다.

이 이벤트는 로컬에서 발생하므로 LocalScript 에만 사용할 수 있습니다.

매개 변수

모드가 변경된 터치 패드.

새로운 모드.


코드 샘플

This example fires when the state of a VRTouchpad changes. It prints the name of the Touchpad that changed, and the state that it changed to.

VRService.TouchpadModeChanged

local VRService = game:GetService("VRService")
VRService.NavigationRequested:Connect(function(pad, mode)
print(pad.Name .. " Touchpad changed to state: " .. mode.Name)
end)

UserCFrameChanged

이 이벤트는 사용자가 연결된 VR 기기이동할 때, 예를 들어, 트래킹하기 위해 Enum.UserCFrame 와 함께 사용됩니다. GetUserCFrame() 코디네이션을 추적

이 이벤트는 로컬에서 발생하므로 LocalScript 에만 사용할 수 있습니다.

매개 변수

변경된 VR 장치의 유형입니다.

value: CFrame

변경 후 VR 장치의 새로 고친 CFrame 좌표.


코드 샘플

This event fires when the user moves a connected VR device. When the event fires, this prints the name of the VR device type that changed, and the updated CFrame coordinates.

VRService.UserCFrameChanged

local VRService = game:GetService("VRService")
VRService.UserCFrameChanged:Connect(function(userCFrameType, cframeValue)
print(userCFrameType.Name .. " changed. Updated Frame: " .. tostring(cframeValue))
end)

UserCFrameEnabled

이 이벤트는 Enum.UserCFrame 가 활성화되거나 비활성화되면 발생합니다. 이 이벤트는 GetUserCFrameEnabled() 와 함께 사용하면 특정 UserCFrame 가 활성화되었는지 여부를

이 이벤트는 로컬에서 발생하므로 LocalScript 에만 사용할 수 있습니다.

매개 변수

UserCFrame|UserCFrame 을 활성화하거나 비활성화합니다.

enabled: bool

UserCFrame|UserCFrame 을 사용하도록 설정( true )또는 사용하지 않도록 설정( false )을 나타내는 부울입니다.


코드 샘플

This example fires when a UserCFrame changes state, printing the name of the changed UserCFrame and whether it changed got enabled or disabled.

VRService.UserCFrameEnabled

local VRService = game:GetService("VRService")
VRService.UserCFrameEnabled:Connect(function(type, enabled)
if enabled then
print(type.Name .. " got enabled!")
else
print(type.Name .. " got disabled!")
end
end)