Trouble with VR Teleporting https://devforum.roblox.com/t/vr-sandbox-opensourced-place-file/1562818

You can write your topic however you want, but you need to answer these questions:

I’m using the link in the title as the basic building blocks for my VR game, I’m trying to make the player teleport using any method

unfortunately there seems to be a local script that uses renderstep as a way of movement and moves using previous locations, thus if I make a big jump from one spot to the other, will not take me to the desired spot, I can’t give screenshots or video because I can’t find ways to record on my oculus at the moment

I tried editing the script and workaround methods such as deleting and cloning a new character and body positions and body velocities but I believe the VR character is anchored thus those wont work. Maybe something with tweens? wouldn’t want that because some teleports go so far and it would make it look weird

Heres the code that I think stops teleports from happening, It should be from this script which is a local script in StarterPlayerScripts

-- // Camera
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CameraSubject = nil
Camera.CFrame = CFrame.new(0, 35, 0)
Camera.HeadScale = ScaleInt*ScaleMult

-- // Character
local Character, CameraPart = require(ReplicatedStorage.Storage.Modules:WaitForChild("CharacterRequester"))(0.75)
--local Character, CameraPart = require(ReplicatedStorage.Storage.Modules:WaitForChild("CharacterRequester"))(Camera.HeadScale)
local Head = Character:WaitForChild("Head")
local RightHand = Character:WaitForChild("Right Arm")
local LeftHand = Character:WaitForChild("Left Arm")

-- // Modules
local NoColl = require(ReplicatedStorage.Storage.Modules:WaitForChild("NoCCVR"))
NoColl.RemoveAllCollisions(Character)

-- // Settings
local ThumbStick1 = Vector3.new()
local Velocity = Vector3.new()
local TSY = 0

local CameraPosition = Camera.CFrame

local SpeedDivider = 10
local LastUserPosition = VRService:GetUserCFrame(Enum.UserCFrame.Head).Position

local Turn = CFrame.fromEulerAnglesXYZ(0, 0, 0)
local IsTurning = true

local RightHaptic = 0
local LeftHaptic = 0

local isTeleporting = false

-- // Cool things
function MultiplyCFrame(CF, Mult)
	local NewPosition = CF.Position * Mult
	local Rotation = CF - CF.Position
	
	return Rotation + NewPosition
end

function GetHeadlockedCFrame()
	local UserCFrame = VRService:GetUserCFrame(Enum.UserCFrame.Head)
	UserCFrame = MultiplyCFrame(UserCFrame, Camera.HeadScale)
	return CFrame.fromEulerAnglesXYZ(UserCFrame:ToEulerAnglesXYZ()) * UserCFrame:Inverse()
end

function GetUserCFrames()
	local HeadCFrame = VRService:GetUserCFrame(Enum.UserCFrame.Head)
	local RightCFrame = VRService:GetUserCFrame(Enum.UserCFrame.RightHand)
	local LeftCFrame = VRService:GetUserCFrame(Enum.UserCFrame.LeftHand)	
	
	return HeadCFrame, RightCFrame, LeftCFrame
end

function CalculateCameraCFrame(HeadCFrame)
	local CameraRotation = Turn * GetHeadlockedCFrame()
	local CameraPos = CameraPosition-- * CFrame.new(0, HeadCFrame.Y*Camera.HeadScale, 0)
	
	local CameraCFrame = CameraPos * CameraRotation
	
	return CameraCFrame, CameraRotation
end

function CalculateHandCFrames(HeadCFrame, RightCFrame, LeftCFrame, Root)
	local Head = Root * MultiplyCFrame(HeadCFrame, Camera.HeadScale)
	local Right = Root * MultiplyCFrame(RightCFrame, Camera.HeadScale)
	local Left = Root * MultiplyCFrame(LeftCFrame, Camera.HeadScale)
	
	return Head, Right, Left
end

function Lerp(A, B, C)
	return A + (B - A) * C
end

function HideHats()
	for Index, Inst in pairs(Character:GetDescendants()) do
		if Inst:IsA("Accessory") then
			local Handle = Inst:FindFirstChildOfClass("Part")
			Handle.LocalTransparencyModifier = 1
		end
	end
end

----- // Connections
RunService.RenderStepped:Connect(function(Delta)-- // UpdateOnRender Determines where character goes
	local HeadCFrame, RightCFrame, LeftCFrame = GetUserCFrames()	

	local MoveVector = Turn * CFrame.new(HeadCFrame.Position - LastUserPosition).Position
	CameraPosition = CameraPosition + MoveVector * Camera.HeadScale
	CameraPosition = CFrame.new(CameraPosition.X, math.clamp(CameraPosition.Y, -100, 500), CameraPosition.Z) * (CameraPosition-CameraPosition.Position)

	local CameraCFrame, CameraRotation = CalculateCameraCFrame(HeadCFrame)
	local CFrames = {CalculateHandCFrames(HeadCFrame, RightCFrame, LeftCFrame, CameraCFrame)}

	local HandSize = RightHand.Size
	local HandOffset = CFrame.fromEulerAnglesXYZ(math.rad(90), 0, 0) * CFrame.new(0, HandSize.Y / 3, 0)

	Head.AlignPosition.Attachment1.WorldCFrame = CFrames[1]
	RightHand.AlignPosition.Attachment1.WorldCFrame = CFrames[2] * HandOffset
	LeftHand.AlignPosition.Attachment1.WorldCFrame = CFrames[3] * HandOffset

	if (RightHand.Position-(CFrames[2] * HandOffset).p).Magnitude > 3.5*Camera.HeadScale then
		RightHand.CFrame = CFrames[2] * HandOffset
	end

	if (LeftHand.Position-(CFrames[3] * HandOffset).p).Magnitude > 3.5*Camera.HeadScale then
		LeftHand.CFrame = CFrames[3] * HandOffset
	end

	Camera.CFrame = CFrame.new(CameraPart.Position) * CameraRotation	


	if ThumbStick1.Magnitude > 0.15 then
		local CameraLook = Camera:GetRenderCFrame().LookVector
		local Angle = math.atan2(-CameraLook.X, -CameraLook.Z)
		local C3Angle = CFrame.fromEulerAnglesXYZ(0, Angle, 0)

		local NewThumbStick = C3Angle*CFrame.new(ThumbStick1)
		local ThumbStickVelocity = (NewThumbStick.Position+Vector3.new(0,TSY,0))/SpeedDivider
		Velocity = ThumbStickVelocity
	else
		Velocity = Vector3.new(0,TSY/SpeedDivider,0)
	end

	HapticService:SetMotor(Enum.UserInputType.Gamepad1, Enum.VibrationMotor.RightHand, RightHaptic)
	HapticService:SetMotor(Enum.UserInputType.Gamepad1, Enum.VibrationMotor.LeftHand, LeftHaptic)

	RightHaptic = Lerp(RightHaptic, 0, 0.2 * (Delta* 60))
	LeftHaptic = Lerp(LeftHaptic, 0, 0.2 * (Delta* 60))

	CameraPosition = CameraPosition + ((Velocity * (Delta * 60))*Camera.HeadScale)

	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CameraSubject = nil

	LastUserPosition = HeadCFrame.Position

	HideHats()
end)

Any help would be appreciated

1 Like