You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make VR hands that use a glove mesh that track the controllers and have physics collisions. (don’t pass through walls, knock stuff down, etc) -
What is the issue? Include screenshots / videos if possible!
It’s just not working. Controllers are being tracked as if you select the AlignOrientation or AlignPosition, it is being tracked in game. It is just for some reason, really far down from the player. (under the map) -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
It has been 6 hours.
local VRService = game:GetService("VRService")
local UserInputService = game:GetService("UserInputService")
local starterGui = game:GetService("StarterGui")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local camera = workspace.CurrentCamera
camera.CameraType = "Scriptable"
camera.HeadScale = 1
local SettingsModule = require(script.SettingsModule)
local isDebug = SettingsModule.DEBUG_MODE
if not VRService.VREnabled and not isDebug then
game.Players.LocalPlayer:Kick("VR NOT DETECTED | PLEASE REJOIN ON A VIRTUAL REALITY HEADSET.")
end
local Player = script.Parent.Parent
local Char = workspace.GameFolder.NonVrCharModels:WaitForChild(Player.Name)
Char:WaitForChild("HumanoidRootPart").Anchored = true
camera.CFrame = CFrame.new(workspace.CurrentCamera.CFrame.Position)
starterGui:SetCore("VRLaserPointerMode", 0)
starterGui:SetCore("VREnableControllerModels", false)
local function createHand(handType: R_L_W?)
if handType == "L" then
local selectedHand = ReplicatedStorage.Resources.HandModels.LeftHandFolder.handL
local handL = selectedHand:Clone()
local attachment0 = Instance.new("Attachment")
attachment0.Name = "Attachment0"
attachment0.Parent = handL.glove
handL.Parent = Char
handL.CFrame = Char.HumanoidRootPart.CFrame
if isDebug then
warn("CreateHand function called: handType = " .. handType)
end
print(handL)
return handL
elseif handType == "R" then
local selectedHand = ReplicatedStorage.Resources.HandModels.RightHandFolder.handR
local handR = selectedHand:Clone()
handR.Parent = Char
handR.CFrame = Char.HumanoidRootPart.CFrame
if isDebug then
warn("CreateHand function called: handType =" .. handType)
end
return handR
--[[
elseif handType == "W" then
local selectedHand = script:FindFirstChild("RightHand")
local RightHand = selectedHand:Clone()
RightHand.CFrame = Char.HumanoidRootPart.CFrame
--]]
end
end
local handLeft = createHand("L")
local handRight = createHand("R")
VRService.UserCFrameChanged:Connect(function(part, move)
if part == Enum.UserCFrame.LeftHand then
warn("part = enum.usercframe.lefthand")
-- handLeft.CFrame = camera.CFrame * cFrame
local alignPosition = handLeft.glove:FindFirstChildOfClass("AlignPosition") or Instance.new("AlignPosition")
alignPosition.Mode = Enum.PositionAlignmentMode.OneAttachment
alignPosition.Attachment0 = handLeft.glove.Attachment0
alignPosition.Position = move.Position
alignPosition.Responsiveness = 200
alignPosition.Parent = handLeft.glove
local alignOrientation = handLeft.glove:FindFirstChildOfClass("AlignOrientation")
or Instance.new("AlignOrientation")
alignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
alignOrientation.Attachment0 = handLeft.glove.Attachment0
alignOrientation.CFrame = move
alignOrientation.Responsiveness = 200
alignOrientation.Parent = handLeft.glove
elseif part == Enum.UserCFrame.RightHand then
warn("part = enum.usercframe.righthand")
-- handRight.CFrame = camera.CFrame * cFrame
local alignPosition = handRight.glove:FindFirstChildOfClass("AlignPosition") or Instance.new("AlignPosition")
alignPosition.Mode = Enum.PositionAlignmentMode.TwoAttachment
alignPosition.Attachment0 = handRight.glove.Attachment0
alignPosition.Position = move.Position
alignPosition.Responsiveness = 200
alignPosition.Parent = handRight.glove
local alignOrientation = handRight.glove:FindFirstChildOfClass("AlignOrientation")
or Instance.new("AlignOrientation")
alignOrientation.Mode = Enum.OrientationAlignmentMode.OneAttachment
alignOrientation.Attachment0 = handRight.glove.Attachment0
alignOrientation.CFrame = move
alignOrientation.Responsiveness = 200
alignOrientation.Parent = handRight.glove
end
end)
--[[
UserInputService.UserCFrameChanged:Connect(function(part, move)
if part == Enum.UserCFrame.LeftHand then
handLeft.CFrame = camera.CFrame * move
elseif part == Enum.UserCFrame.RightHand then
handRight.CFrame = camera.CFrame * move
end
end)
--]]
--[[
VRService.UserCFrameChanged:Connect(function(part, move)
camera.CFrame = CFrame.new(Char.HumanoidRootPart.Position) + Vector3.new(0, 5, 0)
if part == Enum.UserCFrame.LeftHand then
Char.HumanoidRootPart.LHand.WorldCFrame = camera.CFrame * move
elseif part == Enum.UserCFrame.RightHand then
Char.HumanoidRootPart.RHand.WorldCFrame = camera.CFrame * move
end
end)
--]]