PlayerViewService
非推奨を表示
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
PlayerViewService は、プレイヤーのビューに関する追加情報を取得する方法を提供します。
概要
方法
ワールドスペースを返す CFrame プレイヤーのキャラクターを見ています。
プロパティ
方法
GetDeviceCameraCFrame
ワールドスペースを返し、CFrame プレイヤーのキャラクターを見て、現在のカメラの CFrame を設定すると、そのキャラクターをデバイスの視点から見ることができます。
このメソッドはデバイスのカメラを利用し、モバイルデバイスでのみ機能します。情報がない場合、例えばユーザーがモバイルデバイスにいないか、カメラがオンになっていない場合、このメソッドは CFrame.identity を返します。
このメソッドのサンプル実装は、Roblox Connect を参照してください。
パラメータ
戻り値
ワールドスペース CFrame プレイヤーのキャラクターを見たり、または CFrame.identity (説詳細を参照)。
コードサンプル
Updates the local player's camera by using PlayerViewService:GetDeviceCameraCFrame(). This method returns a world space CFrame looking at the player's character, such that setting the current camera's CFrame will view that character from the perspective of their device.
PlayerViewService:GetDeviceCameraCFrame()
local PlayerViewService = game:GetService("PlayerViewService")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local camera = Workspace.CurrentCamera
local function updatePictureInPictureCamera()
camera.CFrame = PlayerViewService:GetDeviceCameraCFrame(player)
end
RunService:BindToRenderStep(
"PictureInPictureCamera",
Enum.RenderPriority.Camera.Value + 1,
updatePictureInPictureCamera
)