主题
WindForce
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(5 属性 / 28 函数 / 6 事件)
- [WindForce](12 属性)
继承成员
1 个来源 / 5 属性 / 28 函数 / 6 事件
- 来自 Unit(5 属性 / 28 函数 / 6 事件)
- 属性:
AssetId、Name、Desc、Parent、Tags - 函数:
ClearAllChildren、GetChildren、GetDescendants、IsAncestorOf、IsDescendantOf、FindFirstAncestor、FindFirstAncestorWhichIsA、FindFirstAncestorOfClass、FindFirstChild、FindFirstChildWhichIsA、FindFirstChildOfClass、HasChildren、GetChildCount、GetChildAtIndex、SetAttribute、GetAttribute、GetAllProps、Clone、IsA、Destroy、GetPropertyChangedSignal、GetAttributeChangedSignal、FindFromPath、GetFullPath、GetDebugId、HasTag、AddTag、RemoveTag - 事件:
ChildAdded、ChildRemoved、DescendantAdded、DescendantRemoving、AncestryChanged、Destroying
- 属性:
局部风场单位,在圆形范围内对支持风场贴图的植被施加摆动,并可通过风场类型在吸附、锥形、扇形、波浪等形态间切换。影响半径与强度决定作用范围与力度,风口半径和风口渐变宽度塑造中心区域的吸力分布,淡入时间与淡出时间以秒为单位让效果平滑出现与消退。绘制优先级用于多个风场重叠时的表现排序,关闭启用后风场停止作用。
适用场景
常用于制作抽风机、吸尘口、通风管道口等局部气流表现,让角色靠近时周围草叶朝风口方向倾倒;把它挂在可移动的模型或挂点下,风场即可跟随装置一起移动。
使用要点
先调用 game:CreateUnit("WindForce", config) 或 World:CreateUnit("WindForce", config) 创建实例,在配置中给出 Position、Radius、Intensity,并把 WindType 设为 Enums.WindForceType.Suction 获得吸附表现。若希望风口中心区域不被吹倒,可调大 VentRadius,再用 VentFadeWidth 控制风口外侧吸力由弱到强的过渡距离。需要平滑启停时配合 FadeInTime 与 FadeOutTime,也可用 Task:Delay 分步修改属性观察变化;最后用 Enabled 控制开关、用 RenderPriority 处理多个风场重叠时的绘制顺序。
注意事项
风场只对支持风场贴图的植被生效,不会对普通模型或角色产生物理推力。实例只能通过创建接口或公开返回值获取,不能直接构造;需要跟随物体移动时应把它挂到对应模型或挂点下,而不是逐帧重设位置。VentFadeWidth 取值很小时风口与外侧的过渡会显得生硬,建议先确定 Radius 与 Intensity 再细调风口参数。
代码示例
创建 WindForce 实例
lua
-- @runtime client
local World = game:GetService('World')
local windForce = World:CreateUnit('WindForce', {})
if windForce == nil then return end
print('WindForce 已创建:', windForce.Name)属性 (12)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
Position | Vector3 | [0.0, 0.0, 0.0] | 位置 |
Rotation | Quaternion | [0.0, 0.0, 0.0, 1.0] | WindForce 的 Rotation 属性,类型为 Quaternion(四元数),用于描述风场自身的朝向。该属性可读写,默认值为 (0, 0, 0, 1),即不做额外旋转。 |
Enabled | Bool | true | 布尔属性,表示该风场(WindForce)是否处于启用状态。 |
WindType | WindForceType | Enums.WindForceType.Suction | 枚举属性,表示风场的类型,取值来自 WindForceType 枚举,包含 Suction、Conical、Sector、Wave 四种。 |
Radius | Float | 4.0 | 浮点属性,表示风场的影响半径。 |
Intensity | Float | 0.6 | 浮点属性,表示风场的作用强度。 |
RenderPriority | Int | 0 | 整型属性,表示风场的绘制优先级。 |
TargetOffset | Vector3 | [0.0, 0.0, 0.0] | 吸引目标偏移 |
VentRadius | Float | 0.75 | 浮点属性,表示风场风口区域的半径。 |
VentFadeWidth | Float | 0.4 | 浮点属性,表示风口外侧渐变过渡带的宽度。 |
FadeInTime | Float | 0.1 | 浮点属性,表示风场淡入所需的时间。 |
FadeOutTime | Float | 0.1 | 浮点属性,表示风场淡出所需的时间。 |
