Confused about UserCFrame.Floor

,

I’ve been trying to implement Enum.UserCFrame.Floor in my VR project to get the player’s real life height. When testing, I realized that the Floor and Head UserCFrame are both by default at (0, 0, 0), meaning there isn’t any way to get the player’s height from it. Unless I’m misunderstanding the Enum, doesn’t that make it completely useless? Thanks.

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

RunService.RenderStepped:Connect(function()
	local FloorCFrame = VRService:GetUserCFrame(Enum.UserCFrame.Floor)
	local HeadCFrame = VRService:GetUserCFrame(Enum.UserCFrame.Head)

	local Height = (HeadCFrame.Y - FloorCFrame.Y)-- Get the distance between both returned CFrames

	print(Height)
end)

This prints 0 every frame, unless the player crouches up or down in real life.

You probably need to get this after physics simulation
etc RunService.PostSimulation

The problem is what the Enum is returning, not when you retrieve it.

it doesnt return enum.
It returns CFrame.
You seem to not understand how cframes work.

HeadCFrame.Position.Y - FloorCFrame.Position.Y

Is what you probably want

I understand it, my point is that the returned CFrame is inaccurate.

You sure that you tested that?

Have you tried checking that in PostSimulation?
Have you tried looking at cframe.Position in raw form without substracting it?

Yes I tried PostSimulation, but again that shouldn’t affect what GetUserCFrame returns and it didn’t change anything. Looking at the unchanged CFrame it’s still wrong based on what I would expect it to return.

1 Like