能力 在 角色控制器库 (CCL) 中评估角色可以做什么,例如跑、跳、爬和游泳的能力。CCL 允许灵活的行为组合,而不是依靠像 Enum.HumanoidStateType 中那样的刚性引擎定义的角色状态,例如角色可以在瞄准和蹲伏的同时移动。
启用 CCL
CCL是通过Studio的头像设置窗口自选的。要启用它:
在头像标签中,打开头像设置。

在窗口左侧选择移动标签,然后在能力部分选择角色控制器库。

所有标准能力如奔跑、跳跃和攀爬默认启用。要在运行时禁用其中任何一个,请取消选中相关框。
配置
在游戏运行时(或通过从 ServerScriptService 运行的脚本),您可以尝试内置的能力配置。您还可以修改特定的 控制器 以调整角色的物理仿真及其与环境的交互,例如角色的基础移动速度。
运行时
要在运行时试验能力配置:
开始一次游戏测试。
选择其中一个内置能力,并在 属性 窗口的 属性 部分自定义下面提到的 属性。
能力 属性 Climbing - SpeedMultiplier — 当角色在爬墙时,与 ClimbController.MoveSpeedFactor 属性的乘数。
Dead - Enabled — 当生命值为 0 或更低时角色死亡。
- Health ⇔ Humanoid.Health
- MaxHealth ⇔ Humanoid.MaxHealth
- RequiresNeck ⇔ Humanoid.RequiresNeck
FacingMoveDirection - Enabled ⇔ Humanoid.AutoRotate
FallingDown Freefall - SpeedMultiplier — 当角色自由落体时,与 AirController.MoveSpeedFactor 属性的乘数。请注意,当角色自由落体的持续时间非常短时,效果可能很微妙。
GettingUp Jumping - JumpHeight ⇔ Humanoid.JumpHeight
- JumpPower ⇔ Humanoid.JumpPower
- UseJumpPower ⇔ Humanoid.UseJumpPower
NoLocomotion Running - SpeedMultiplier — 当角色在奔跑时,与 GroundController.MoveSpeedFactor 属性的乘数。
Sitting Swimming - EnableFastRise — 通过保持跳跃输入更快地上升到水面。
- SpeedMultiplier — 当角色在游泳时,与 SwimController.MoveSpeedFactor 属性的乘数。
脚本化
要通过脚本设置所有角色的能力配置:
在 ServerScriptService 中创建一个新的服务器端 Script,并将其重命名为 AbilitiesScript。
将以下代码复制并粘贴到新脚本中。此示例将 Running 能力的基础移动速度乘以 2。可以根据 上表 中描述的其他能力属性来调整。
Script in ServerScriptServicelocal Players = game:GetService("Players")local function onCharacterAdded(character)local AbilityManagerActor = character:WaitForChild("AbilityManagerActor")local Abilities = AbilityManagerActor:WaitForChild("Abilities")local Running = Abilities:FindFirstChild("Running")if Running then-- 将基础移动速度翻倍Running:SetAttribute("SpeedMultiplier", 2)endendlocal function onPlayerAdded(player)if player.Character thenonCharacterAdded(player.Character)endplayer.CharacterAdded:Connect(onCharacterAdded)endPlayers.PlayerAdded:Connect(onPlayerAdded)
