Menu
CoddyTech

점프 패드

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

Bounce 스테이지에는 Bounce 태그가 붙은 초록색 패드가 있으며, 패드는 뛰어오르기에는 너무 높은 턱 아래에 있습니다. 패드에 착지하면 위로 튀어 올라 턱 위에 올라가야 합니다.

캐릭터는 가운데에 있는 보이지 않는 파트인 HumanoidRootPart와 함께 움직입니다. 이 파트의 AssemblyLinearVelocity를 설정하면 캐릭터가 그 방향으로 날아오르고, 중력에 의해 다시 내려옵니다.

root.AssemblyLinearVelocity = Vector3.new(0, 60, 0) -- 초당 60스터드, 수직 위로

Touched는 패드에 부딪힌 팔다리를 전달하며, 보통 다리입니다. 그 팔다리의 부모는 캐릭터이며, 캐릭터에는 HumanoidRootPart가 있습니다.

challenge icon

챌린지

중급

초록색 발판이 너를 선반까지 튀어 오르게 하세요.

  1. bounce(hit)를 작성하세요. hit.Parent에 HumanoidRootPart가 있으면, 해당 항목의 AssemblyLinearVelocity를 Vector3.new(0, Settings.BouncePower, 0)로 설정하세요.
  2. setupStage에서 Bounce 태그가 지정된 모든 파트의 Touched를 이 함수에 연결하세요.

‘플레이’를 누르고 초록색 발판을 밟으세요. 발판이 너를 선반 옆까지 튀어 오르게 합니다. 그런 다음 ‘확인’을 누르세요.

직접 해보기

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

-- Lesson 10: Bounce Pads는 여기에 들어갑니다

-- 스피너는 매 프레임 조금씩 회전합니다
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
	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()

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

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