Menu
CoddyTech

차오르는 용암

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

아래에서 기다리는 것은 안전하지 않아야 합니다. 용암판은 타워 아래에서 시작하여 Settings.LavaDelay초 후 꾸준히 상승하다가 꼭대기에서 2스터드 아래에 도달하므로, 모두 계속 올라가야 합니다.

트윈은 시작 전에 기다릴 수 있습니다. TweenInfo.new의 여섯 번째 인수는 초 단위 지연 시간입니다. 꾸준히 상승하게 하려면 트윈 시간은 거리 나누기 속도입니다.

-- 4초 후, 초당 3스터드로 60스터드 이동
local info = TweenInfo.new(60 / 3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 4)

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

challenge icon

챌린지

중급

용암이 타워 아래에서 올라옵니다.

  1. buildTower가 top을 반환하도록 만들고, 스크립트를 startLava(buildTower())로 끝내세요.
  2. startLava(top)을 작성하세요. 최상위 lava를 고정된 Lava라는 이름의 Part로 설정하고, CanCollide를 false로 설정한 뒤 (0, -2, 0) 위치에 두고, Touched를 killOnTouch에 연결하세요.
  3. top / Settings.LavaSpeed초 동안 Linear 방식으로, Settings.LavaDelay만큼 지연한 후 용암을 (0, top - 2, 0) 위치로 트윈하세요.

‘플레이’를 누르세요. 10초 후 용암이 여러분 아래에서 올라오기 시작합니다. 그런 다음 ‘확인’을 누르세요.

직접 해보기

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

-- 레슨 11: 솟아오르는 용암을 여기에 추가합니다

buildTower()
quiz icon실력 점검

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

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

직접 연습해 보세요: Roblox 플레이그라운드