見出し画像

ソースコード

ブログのソースコードです。

ブログ:VRサイクリングの試作1

ConveyorのScript

local conveyor = script.Parent
local speed = conveyor.Configuration.Speed.Value
speed = 5
conveyor.Velocity = conveyor.CFrame:vectorToWorldSpace(Vector3.new(speed, 0, 0))

TeleportのTeleportScript

local Teleport1A = script.Parent.Teleport1A
local Teleport1B = script.Parent.Teleport1B

-- A -> B へテレポート
local function TeleportA2B(part)
	local humanoid = part.Parent:FindFirstChild("HumanoidRootPart")
	if humanoid then
		-- プレイヤーの位置をテレポートブロックBにする
		humanoid.CFrame = Teleport1B.CFrame + Vector3.new(-10,0,0)
	end
end

-- B -> A へテレポート
local function TeleportB2A(part)
	local humanoid = part.Parent:FindFirstChild("HumanoidRootPart")
	if humanoid then
		-- プレイヤーの位置をテレポートブロックAにする
		humanoid.CFrame = Teleport1A.CFrame + Vector3.new(0,0,10)
	end
end

Teleport1A.Touched:Connect(TeleportA2B)
Teleport1B.Touched:Connect(TeleportB2A)

Teleport1A, Teleport1BのScript

while true do
	script.Parent.Transparency = 0
	wait(1)
	script.Parent.Transparency = 0.7
	wait(1)
end

この記事が気に入ったらサポートをしてみませんか?