Ive recently been interested in Roblox’s VR service, and wanted to start on a VR game of my own. Im trying to create a physics based VR system, (climbing, jumping, etc) and I’m pretty sure I know where to start, but I don’t know how to do it. Im assuming I need to use a sphere below the player for locomotion, so something like this.
Ive been stuck here because I need to keep the sphere beneath the camera even if they lean in their real life playspace, but also allow things like the players hands to affect the whole character. In case your wondering, I do have scripting experience so I don’t need an entire script or anything. Any help is highly appreciated, thanks!
2 Likes
Hi there, for climbing i would suggest for you to use a “ControlPartSensor” now this doesnt make you climb, its just a sensor - having this attached to a basepart of your model would help since you can get targets based on the Floor or Ladder. Given in its properties you can change the sensor mode to “Floor” or “Ladder” and also change the SensorDistance to how far you want to find your target. With a script you can get your target then you can add a glue or weld when grabbing that target. Character Controllers | Documentation - Roblox Creator Hub --Depending on how far apart each part is the sensor can track easily on each target one by one i assume.
You can do this completely different though, most people make a variable thats stated as nil and then check if Target:IsA(“Part”) when touched also check if that target has a grab boolean then glues/welds to players part when userinput is connected while touching part. Jumping should be by the humanoid, if that doesnt work, make sure that character is a model and has a Humanoid. i can show you a script of what vr heads and hands might be.
--Services
local VRService = game:GetService("VRService")
local Camera = game.Workspace.CurrentCamera
--Character
local character = script.Parent
--Character Children
local Head = character:FindFirstChild("Head")
local RightArm = character:FindFirstChild("Right Arm")
local LeftArm = character:FindFirstChild("Left Arm")
function UpdateUserCFrame()
local HeadVR = VRService:GetUserCFrame(Enum.UserCFrame.Head):ToWorldSpace(CFrame.new()) --this might not be correct, remember though that this client replicates the head and hands
Head.CFrame = HeadVR
local RightHand = VRService:GetUserCFrame(Enum.UserCFrame.RightHand):ToWorldSpace(CFrame.new()) * CFrame.Angles(math.rad(90), 0, 0)
RightArm.CFrame = RightHand
local LeftHand = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand):ToWorldSpace(CFrame.new()) * CFrame.Angles(math.rad(90), 0, 0)
LeftArm.CFrame = LeftHand
end
VRService.UserCFrameChanged:Connect(UpdateUserCFrame)
for the hands or head to stay in place with your rootpart i would suggest using AlignPosition and AlignOrientation Instances, as this helps the replication for the head and hands to stay on the character.
I hope this helped, if i am wrong please suggest other things!
EDIT: I JUST REALISE THIS WAS MADE A YEAR AGO :\ wanted to help.
1 Like