How do i make advanced VR movement?

I’m working on a VR game, and I’m really struggling here, i want to have blade and sorcery physics-based style movement and i don’t even know where to begin, I already added in hand movement, so now its a matter of perfecting the body.

There’s a few issues i can’t figure out

  1. How can i make the body walk when you tilt the left joystick
  2. How can i adjust the body with real life movement without breaking in game movement

Also I’m not asking for code, simply help with designing a system which i can then translate into code, the reason I don’t want to use open source systems is because I prefer starting from scratch, and it makes it more customizable for me.

I’m kinda new to VR development so I really don’t know what to do with these, here’s what i have so far:

https://gyazo.com/055f889093a1a86d49d3a707f7ed7ff2

As you can see, the body is all weird and janky, and it’s completely misaligned with the head, this is my code:

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")


local Camera = workspace.CurrentCamera
Camera.HeadLocked = true


-- Services --
local VRService = game:GetService("VRService")

-- Functions --

local function CreateHand(Hand)
	local Part = Instance.new("Part")
	Part.Shape = Enum.PartType.Ball
	Part.Size = Vector3.new(0.3,0.3,0.3)
	Part.Anchored = true
	Part.Massless = true
	Part.CanCollide = false
	Part.CanTouch = false
	Part.Parent = Character
	Part.Transparency = 0.5
	Part.Material = Enum.Material.ForceField
	Part.Color = Color3.fromRGB(72, 0, 255)
	Part.Name = Hand.."HandDisp"
	
	return Part
end

local function CreateIK(Name,T,C,E)
	local IK = Instance.new("IKControl")
	IK.Parent = Character.Humanoid
	IK.EndEffector = E
	IK.ChainRoot = C
	IK.Target = T
	IK.Name = Name
	IK.SmoothTime = 0
	IK.Priority = 50
	
	return IK
end

-- Hands --

local RightHandCF = nil
local handOffsetR = VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
handOffsetR = handOffsetR.Rotation + handOffsetR.Position * workspace.CurrentCamera.HeadScale
RightHandCF = handOffsetR
local RightHand = CreateHand("Right")
 
local LeftHandCF = nil
local handOffsetL = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
handOffsetL = handOffsetL.Rotation + handOffsetL.Position * workspace.CurrentCamera.HeadScale
LeftHandCF = workspace.CurrentCamera.CFrame * handOffsetL
local LeftHand = CreateHand("Left")

-- ArmIK --
local IK1 = CreateIK("RightArmIK",RightHand,Character:WaitForChild("RightUpperArm"),Character:WaitForChild("RightHand"))

local IK2 = CreateIK("LeftArmIK",LeftHand,Character:WaitForChild("LeftUpperArm"),Character:WaitForChild("LeftHand"))


game:GetService("RunService").RenderStepped:Connect(function()
	-- Alignment --
	
	handOffsetL = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)
	handOffsetL = handOffsetL.Rotation + handOffsetL.Position * workspace.CurrentCamera.HeadScale
	LeftHandCF = workspace.CurrentCamera.CFrame * handOffsetL

	handOffsetR = VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
	handOffsetR = handOffsetR.Rotation + handOffsetR.Position * workspace.CurrentCamera.HeadScale
	RightHandCF = workspace.CurrentCamera.CFrame * handOffsetR

	LeftHand.CFrame = LeftHandCF * CFrame.fromOrientation(math.rad(90),0,0)
	RightHand.CFrame = RightHandCF * CFrame.fromOrientation(math.rad(90),0,0)
end)

All help is greatly appreciated

3 Likes

Okay, what exactly do you mean by “real life movement”

For the first part, you could make your custom character model have a humanoid and make them have Roblox’s base movement system or you’d have to use things like Vector Force constraints to give the player the idea of movement. For me personally, I just used the base Roblox model and made their normal body (their arms, legs, torso, etc.) move with their arms using Align Position. This is because the humanoid root part is all you really need to use Roblox’s movement system.

1 Like

When i say “real life movement”, i’m referring to when the player actual moves around outside of the game and physically walks around, roblox’s built in movement system doesn’t really account for this in first person

As for hand movement, i want it to use IK so that the player’s in game arms follow it, i already figured out inverse kinematics though since roblox has it built in, so im not really worried about that

What I would do to make the body walk when you tilt the left joystick is to not replace the starter player but instead just make it invisible and add your own custom character.

Problem with that is then the invisible player is still your hitbox

that seems like it would bring up a lot of issues though, as aurius bat said, the actual character still has collision, and the default roblox system for your character automatically moves the character when you tilt the joystick, so i’d have to make a custom system either way

did you ever figure this out? ive been trying to find a way to translate the players in game movement with not only joystick movement, but also if the player moves in real life

code wise i never got around to it, but if i base the movement around the head rather than the body i can account for it, of course this would mean a system to align the body with the head and the world, but overall it should work

1 Like