Menu
CoddyTech

熄灯

Coddy Roblox 游戏:逃离黑暗 课程的第 1 课,共 25 课。

在这门课程中,你将制作一款密室逃脱游戏:一间间黑暗的房间依次开启,你需要使用手电筒和钥匙找到金库,还要躲藏、奔跑并寻找出口,避开追捕你的怪物。游戏的恐怖感来自黑暗,而不是血腥内容。

Lighting 服务负责营造场景氛围。ClockTime 表示小时(0 表示午夜,因此没有阳光),Ambient 表示天空照不到的地方(例如室内)的光线,OutdoorAmbient 表示室外的光线,而雾会遮住远处的景物:

Lighting.ClockTime = 0
Lighting.FogColor = Color3.new(0, 0, 0)
Lighting.FogEnd = 120 -- 你能看到 120 studs 以内的景物,再远就是黑色了

这些数字来自 ReplicatedStorage.Settings,因此你可以在一个地方调整黑暗程度。

challenge icon

挑战

简单

让游戏进入夜晚。

  1. 将 Lighting.ClockTime 设置为 Settings.ClockTime。
  2. 将 Lighting.Ambient 和 Lighting.OutdoorAmbient 设置为 Settings.Ambient。
  3. 将 Lighting.FogColor 设置为 Color3.new(0, 0, 0),并将 Lighting.FogEnd 设置为 Settings.FogEnd。
  4. 打印 Lights out。

按“开始”:大厅会变暗,黑色的雾会逐渐笼罩过来。然后按“检查”。

亲手试试

-- DarkServer:在服务器上运行游戏的 Script。
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local Lighting = game:GetService("Lighting")
local Settings = require(game.ReplicatedStorage.Settings)

-- 切换到夜晚:设置 Lighting 的 ClockTime、Ambient、OutdoorAmbient、
-- FogColor(黑色),并根据 Settings 设置 FogEnd。然后打印 "Lights out"。

Roblox 游戏:逃离黑暗中的所有课

自己练习: Roblox 在线编辑器