AlignPosition does not move parts until a minute later

I am making a VR game and there should be hands that track the controllers and interact with physics. To do this I am using AlignPosition and AlignOrientation.

However, I have to wait a minute for the parts making up the hands to move.

(why is video uploading not working)

I have set the physics ownership(even though it was parented to the character) and used :SetPrimaryPartCFrame() and setting the CFrame of a part. (Edit 2: Works on server side. I was doing it client-side) These still don’t work.

It’s not a sleep issue as I tried turning off AllowSleep in studio settings and it still doesn’t work. I’ve also tried making the parts massless but that didn’t work too.

It’s seems to be a issue with all of the constraints I am using to make the hands as turning off the weld between the grabbing area and the hands makes the sphere track the controllers position.

Edit: Server Code:

local Players = game:GetService('Players')
local ServerStorage = game:GetService('ServerStorage')

local LeftHand = ServerStorage.LeftHand
local RightHand = ServerStorage.RightHand

local function SetModelNetworkOwnership(Model, Player) 
	for i, Part in pairs(Model:GetDescendants()) do
		if Part:IsA('BasePart') then
			local CanSetNetworkOwnership, ErrorCode = Part:CanSetNetworkOwnership()
			if CanSetNetworkOwnership == true then
				Part:SetNetworkOwner(Player)
			else
				warn('Can not set network ownership of ' .. Part.Name .. ' because of ' .. ErrorCode)
			end
		end
	end
end

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local LeftHandClone = LeftHand:Clone()
		LeftHandClone.Parent = workspace
		SetModelNetworkOwnership(LeftHandClone, Player)
		LeftHandClone.Parent = Character
		local RightHandClone = RightHand:Clone()
		RightHandClone.Parent = workspace
		SetModelNetworkOwnership(RightHandClone, Player)
		RightHandClone.Parent = Character
	end)
end)

Client Code:

local Players = game:GetService('Players')
local VRService = game:GetService('VRService')

local Player = Players.LocalPlayer

local RoomWorldCenter = CFrame.new()

local Height = 5

local RoomWorldVector3 = Vector3.new(RoomWorldCenter.Position.X, Height, RoomWorldCenter.Position.Y)

local function MakeAlignmentsAndAttachmentAndProxyPart(ProxyParent, ProxyPosition, ProxyName, Attachment0, AttachmentPosition, AttachmentName)
	local ProxyPart = Instance.new('Part')
	ProxyPart.Name = ProxyName
	ProxyPart.Position = ProxyPosition
	
	ProxyPart.Transparency = 1
	ProxyPart.CanCollide = false
	ProxyPart.Anchored = true
	ProxyPart.Size = Vector3.new(0, 0, 0)
	
	ProxyPart.Parent = ProxyParent
	
	local Attachment1 = Instance.new('Attachment')
	Attachment1.Name = AttachmentName
	Attachment1.Position = AttachmentPosition
	Attachment1.Parent = ProxyPart
			
	local AlignPosition = Instance.new('AlignPosition')
	AlignPosition.Attachment0 = Attachment0
	AlignPosition.Attachment1 = Attachment1
	
	AlignPosition.RigidityEnabled = true
	
	AlignPosition.Parent = ProxyPart
	
	local AlignOrientation = Instance.new('AlignOrientation')
	AlignOrientation.Attachment0 = Attachment0
	AlignOrientation.Attachment1 = Attachment1
	
	AlignOrientation.RigidityEnabled = true
	
	AlignOrientation.Parent = ProxyPart
	
	return ProxyPart, Attachment1, AlignPosition, AlignOrientation
end

Player.CharacterAdded:Connect(function(Character)
	local Humanoid = Character:WaitForChild('Humanoid')
	local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')
	local Head = Character:WaitForChild('Head')
	local LeftHand = Character:WaitForChild('LeftHand')
	local RightHand = Character:WaitForChild('RightHand')
	
	-- LeftHand:SetPrimaryPartCFrame(VRService:GetUserCFrame(Enum.UserCFrame.LeftHand) * CFrame.new(RoomWorldVector3))
	-- RightHand:SetPrimaryPartCFrame(VRService:GetUserCFrame(Enum.UserCFrame.RightHand) * CFrame.new(RoomWorldVector3)) Old Client-side CFrame Code
	
	Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
	
	local HumanoidOffest = (Head.Position - HumanoidRootPart.Position).Magnitude
	
	local CenterRootAttachment = Instance.new('Attachment')
	CenterRootAttachment.Name = 'CenterRootAttachment'
	CenterRootAttachment.Position = Vector3.new(0, 0, 0)
	CenterRootAttachment.Parent = HumanoidRootPart
	
	local NoPhysicsRootPart, NoPhysicsRootAttachment, AlignRootPosition, AlignRootOrientation = MakeAlignmentsAndAttachmentAndProxyPart(Character, Vector3.new(0, 0, 0), 'NoPhysicsRootPart', CenterRootAttachment, Vector3.new(0, 0, 0), 'NoPhysicsRootAttachment')
	
	local NoPhysicsLeftHand, NoPhysicsLeftHandAttachment, AlignLeftHandPosition, AlignLeftHandOrientation = MakeAlignmentsAndAttachmentAndProxyPart(Character, Vector3.new(0, 0, 0), 'NoPhysicsLeftHand', LeftHand.GrabSphere.Attachment, Vector3.new(0, 0, 0), 'NoPhysicsLeftHandAttachment')	
	
	AlignLeftHandOrientation.RigidityEnabled = false
	AlignLeftHandOrientation.MaxAngularVelocity = 50
	AlignLeftHandOrientation.MaxTorque = 50
	AlignLeftHandOrientation.Responsiveness = 50
	
	local NoPhysicsRightHand, NoPhysicsRightHandAttachment, AlignRightHandPosition, AlignRightHandOrientation = MakeAlignmentsAndAttachmentAndProxyPart(Character, Vector3.new(0, 0, 0), 'NoPhysicsRightHand', RightHand.GrabSphere.Attachment, Vector3.new(0, 0, 0), 'NoPhysicsRightHandAttachment')	
	
	AlignRightHandOrientation.RigidityEnabled = false
	AlignRightHandOrientation.MaxAngularVelocity = 50
	AlignRightHandOrientation.MaxTorque = 50
	AlignRightHandOrientation.Responsiveness = 50
	
	VRService.UserCFrameChanged:Connect(function(type, value)
		if type == Enum.UserCFrame.Head then
			local HeadsetRealCFrame = value
			local HeadsetRealRotation = HeadsetRealCFrame - HeadsetRealCFrame.Position
			local HeadsetWorldRotation = HeadsetRealRotation * (RoomWorldCenter - RoomWorldCenter.Position)
			
			local HeadsetWorldCFrame = CFrame.new(HeadsetRealCFrame.Position + RoomWorldVector3) * HeadsetWorldRotation
			
			NoPhysicsRootPart.CFrame = HeadsetWorldCFrame:ToWorldSpace(CFrame.new(Vector3.new(0, -HumanoidOffest, 0)))
		elseif type == Enum.UserCFrame.LeftHand then
			local LeftHandRealCFrame = value
			local LeftHandRealRotation = LeftHandRealCFrame - LeftHandRealCFrame.Position
			
			local LeftHandWorldRotation = LeftHandRealRotation * (RoomWorldCenter - RoomWorldCenter.Position)
			
			local LeftHandWorldCFrame = CFrame.new(LeftHandRealCFrame.Position + RoomWorldVector3) * LeftHandRealRotation
			
			NoPhysicsLeftHand.CFrame = LeftHandWorldCFrame
		elseif type == Enum.UserCFrame.RightHand then
			local RightHandRealCFrame = value
			local RightHandRealRotation = RightHandRealCFrame - RightHandRealCFrame.Position
			
			local RightHandWorldRotation = RightHandRealRotation * (RoomWorldCenter - RoomWorldCenter.Position)
			
			local RightHandWorldCFrame = CFrame.new(RightHandRealCFrame.Position + RoomWorldVector3) * RightHandRealRotation
			
			NoPhysicsRightHand.CFrame = RightHandWorldCFrame
		end
	end)
end)

Place file: vr_props.rbxlx (482.3 KB) (vr required)

1 Like

I read this forum earlier and ignored it because it had to do with Virtual Reality, and I am not experienced with Roblox’s system, however since no one has replied I can try to help you out here.

Can you please clarify what you mean by “until a minute later”

1 Like

This is more of a physics problem, than a VR problem. I may try to make a non-VR demostration of the problem.

So I clone the hands from Server Storage to the workspace, then change physics ownership to the player and change the parent of the cloned hand model to the character. Then the client uses AlignPosition and AlignOrientation to move the hands to the controllers. This should be near instantaneous, but is not. I have to wait 30 seconds to 1 minute for the parts to start to move. Additionally, moving the model using :SetPrimaryPartCFrame() does not work at all. Works on the server, not the client.

1 Like

I fixed it by setting the CFrame of the model near the character server side.

1 Like