Menu
CoddyTech

차오르는 용암

Coddy의 Roblox 게임: 끝없는 타워 코스 레슨. 18개 중 10번째.

아래에서 기다리는 것은 안전하지 않아야 합니다. 용암 판이 타워 아래에서 시작해 잠시 지연된 후 꾸준히 상승하며 꼭대기에서 2 studs 아래까지 올라오므로, 모두 계속 올라가야 합니다.

트윈은 시작하기 전에 대기할 수 있습니다. TweenInfo.new의 여섯 번째 인수는 초 단위 지연 시간입니다. 일정한 속도로 상승시키려면 트윈의 시간은 거리 나누기 속도입니다.

local seconds = top / Settings.LavaSpeed
local info = TweenInfo.new(seconds, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, Settings.LavaDelay)

용암은 고체가 아니므로(CanCollide false) 아무도 그 위에 설 수 없으며, 용암의 Touched에는 킬 브릭과 같은 함수인 killOnTouch가 사용됩니다. 용암은 높이 -2에서 시작해 top - 2까지 올라오며, 정확히 top studs만큼 상승합니다.

challenge icon

챌린지

중급
  1. 상단 근처에 local lava = nil을 추가하세요. buildTower가 top을 반환하도록 하세요.
  2. startLava(top)를 작성하세요. 고정된 Part를 만들고 이름을 Lava로 지정하세요. CanCollide는 비활성화하고, 크기는 30 x 2 x 30으로 설정한 뒤 Vector3.new(0, -2, 0) 위치에 배치하세요. 주황색 Neon(Color3.fromRGB(255, 90, 20))으로 설정하고 workspace에 넣은 다음, Touched를 killOnTouch에 연결하세요. top / Settings.LavaSpeed초 동안 Linear로, Settings.LavaDelay만큼 지연한 후 Position을 Vector3.new(0, top - 2, 0)으로 트윈하세요.
  3. 마지막에 local top = buildTower()를 작성하고, 그다음 startLava(top)를 작성하세요.

이 레슨의 용암은 빠르게 움직이므로 확인이 금방 끝납니다. Play를 누른 다음 Check를 누르세요.

직접 해보기

local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local CollectionService = game:GetService("CollectionService")
local RunService = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Settings = require(game.ReplicatedStorage.Settings)

local stages = ServerStorage.Stages
local tower = nil

print("Each tower has " .. Settings.StageCount .. " stages")

-- 모든 플레이어의 리더보드에 Wins가 추가된다
Players.PlayerAdded:Connect(function(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	local wins = Instance.new("IntValue")
	wins.Name = "Wins"
	wins.Parent = leaderstats
end)

-- Kill 태그가 붙은 것에 닿으면 목숨을 잃는다
local function killOnTouch(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.Health = 0
	end
end

-- 사라지는 발판은 누군가 올라서면 잠시 후 희미해졌다가 다시 나타난다
local function makeVanish(part)
	part.Touched:Connect(function(hit)
		if part:GetAttribute("Gone") or not hit.Parent:FindFirstChild("Humanoid") then
			return
		end
		part:SetAttribute("Gone", true)
		task.wait(Settings.VanishDelay)
		part.Transparency = 0.8
		part.CanCollide = false
		task.wait(Settings.VanishTime)
		part.Transparency = 0
		part.CanCollide = true
		part:SetAttribute("Gone", nil)
	end)
end

-- 레이저는 Slide 오프셋 위치까지 이동했다가 돌아오기를 계속 반복한다
local function makeSlide(part)
	local info = TweenInfo.new(Settings.SlideTime, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1, true)
	local goal = { Position = part.Position + part:GetAttribute("Slide") }
	TweenService:Create(part, info, goal):Play()
end

-- 점프 패드는 그 위에 착지한 사람을 공중으로 튕겨 올린다
local function bounce(hit)
	local root = hit.Parent:FindFirstChild("HumanoidRootPart")
	if root then
		root.AssemblyLinearVelocity = Vector3.new(0, Settings.BouncePower, 0)
	end
end

-- 회전 장애물은 매 프레임 조금씩 회전한다
RunService.Heartbeat:Connect(function(dt)
	for _, spinner in CollectionService:GetTagged("Spinner") do
		if spinner:IsDescendantOf(workspace) then
			spinner:PivotTo(spinner:GetPivot() * CFrame.Angles(0, math.rad(Settings.SpinSpeed) * dt, 0))
		end
	end
end)

-- 태그에 따라 스테이지의 모든 장애물을 활성화한다
local function setupStage(stage)
	for _, part in stage:GetDescendants() do
		if part:HasTag("Kill") then
			part.Touched:Connect(killOnTouch)
		end
		if part:HasTag("Vanish") then
			makeVanish(part)
		end
		if part:HasTag("Conveyor") then
			part.AssemblyLinearVelocity = part.CFrame.LookVector * Settings.BeltSpeed
		end
		if part:HasTag("Slider") then
			makeSlide(part)
		end
		if part:HasTag("Bounce") then
			part.Touched:Connect(bounce)
		end
	end
end

-- 스테이지 하나를 무작위로 선택한다
local function pickStage()
	local all = stages:GetChildren()
	return all[math.random(1, #all)]
end

-- 모델의 복사본을 타워 꼭대기에 놓고, 복사본과 새로운 꼭대기 높이를 반환한다
local function stack(template, bottom)
	local copy = template:Clone()
	local box, size = copy:GetBoundingBox()
	local lift = bottom - (box.Position.Y - size.Y / 2)
	copy:PivotTo(copy:GetPivot() + Vector3.new(0, lift, 0))
	copy.Parent = tower
	return copy, bottom + size.Y
end

-- 아래에서 위로 새로운 무작위 타워를 만든다
local function buildTower()
	tower = Instance.new("Model")
	tower.Name = "Tower"
	tower.Parent = workspace
	local top = 0
	for i = 1, Settings.StageCount do
		local stage, newTop = stack(pickStage(), top)
		top = newTop
		setupStage(stage)
	end
	stack(ServerStorage.Finish, top)
end

buildTower()
quiz icon실력 점검

이 레슨에는 짧은 퀴즈가 포함되어 있습니다. 레슨을 시작해 문제를 풀고 진행 상황을 기록하세요.

Roblox 게임: 끝없는 타워의 모든 레슨