跳至正文
版本:bleeding-edge 🩸

基础载具

所有载具实体的基类。

👪Base Class🧑‍💻API Source
👪Base Class
This is a Base Class, an abstract definition that shares common methods and events with it's child classes. You cannot spawn it, and you cannot call anything on the Base Class name itself. Use any class that inherits it.

Classes that share methods and events from this Base Class: VehicleWheeled, VehicleWater.

🦠 函数

ReturnsNameDescription
AddSkeletalMeshAttached附加一个骨骼网格体作为该实体的骨骼主姿态
AddStaticMeshAttached附加一个静态网格体到此实体
functionBindAnimationBlueprintEventDispatcher分配并绑定一个动画蓝图事件分发器
varargs of anyCallAnimationBlueprintEvent调用一个动画蓝图事件或函数
table of stringGetAllSkeletalMeshAttached获取附加到此实体的所有骨骼网格体
table of stringGetAllStaticMeshAttached获取附加到此实体的所有静态网格体
anyGetAnimationBlueprintPropertyValue直接获取动画蓝图的属性/变量值
tableGetDoors获取所有配置的门
SkeletalMesh ReferenceGetMesh获取资产名称
CharacterGetPassenger获取指定座位上的乘客
table of CharacterGetPassengers获取所有乘客
booleanIsEngineStarted检查引擎是否已启动
PlayAnimation在此载具上播放动画
RemoveAllSkeletalMeshesAttached移除所有已附加的骨骼网格体
RemoveAllStaticMeshesAttached移除所有已附加的静态网格体
RemoveSkeletalMeshAttached根据自定义 ID 移除此载具上已存在的骨骼网格体(如果存在)
RemoveStaticMeshAttached根据自定义 ID 移除此载具上已存在的静态网格体(如果存在)
SetAnimationBlueprintPropertyValue直接设置动画蓝图的属性/变量值
SetBuoyancyPontoons设置水体模拟所使用的浮筒
SetBuoyancySettings设置该实体在水中的行为
SetCameraArmLength设置驾驶此载具时相机与载具保持的距离
SetCameraOffset设置载具相机偏移量
SetDoor为载具添加一个车门
SetExplosionSettings配置当生命值归零时的爆炸设置
SetStaticMeshAttachedTransform设置已附加静态网格体的位置和旋转
StopAnimation停止在此载具上播放的动画蒙太奇
UnbindAnimationBlueprintEventDispatcher解绑一个动画蓝图事件分发器

Slow

AddSkeletalMeshAttached

生成并附加一个骨骼网格体到此实体,该骨骼网格体必须使用与此 Actor 的网格相同的骨骼,并且将同步其所有动画。使用自定义 ID 以便随后进行移除/自定义设置
🆕Updated Function
This method was recently updated in ver. 1.144. See the Compatibility Versions page for more information.
my_vehicle:AddSkeletalMeshAttached(id, skeletal_mesh_path, socket?, relative_location?, relative_rotation?, use_parent_bounds?, use_base_leader_pose_component?, animation_path?, attachable_id?)

Parameters

TypeParameterDefaultDescription
stringid Required parameter 后续用于移除或在其上应用材质设置
SkeletalMesh Referenceskeletal_mesh_path Required parameter 要附加的骨骼网格体资产路径
stringsocket?
要附加到的骨骼插槽
Vectorrelative_location?Vector(0, 0, 0)
相对位置
Rotatorrelative_rotation?Rotator(0, 0, 0)
相对旋转
booleanuse_parent_bounds?true
如果为 true,则该组件在附加时使用其父级的边界。当附加许多组件时,这可以带来显著的优化
booleanuse_base_leader_pose_component?true
如果为 true,此组件将使用基础领头姿态组件来复制其动画
Animation Referenceanimation_path?
要在附加的骨骼网格体上播放的动画资产路径
stringattachable_id?
可选,将此组件附加到另一个已附加的骨骼网格体上(而不是附加到根组件上)

See also RemoveSkeletalMeshAttached.


Slow

AddStaticMeshAttached

在插槽中以相对位置和旋转生成并附加一个静态网格体到此载具。使用自定义 ID 以便随后进行移除/自定义设置
my_vehicle:AddStaticMeshAttached(id, static_mesh_path, socket?, relative_location?, relative_rotation?, use_parent_bounds?, attachable_id?)

Parameters

TypeParameterDefaultDescription
stringid Required parameter 分配给该静态网格体的唯一 ID
StaticMesh Referencestatic_mesh_path Required parameter 要附加的静态网格体资产路径
stringsocket?
要附加到的骨骼插槽
Vectorrelative_location?Vector(0, 0, 0)
相对位置
Rotatorrelative_rotation?Rotator(0, 0, 0)
相对旋转
booleanuse_parent_bounds?true
如果为 true,则该组件在附加时使用其父级的边界。当附加许多组件时,这可以带来显著的优化
stringattachable_id?
可选,将此组件附加到另一个已附加的静态网格体上(而不是附加到根组件上)

See also SetStaticMeshAttachedTransform, RemoveStaticMeshAttached.


Slow

BindAnimationBlueprintEventDispatcher

指定并绑定动画蓝图事件分发器。

注:VehicleWheeled 拥有动画蓝图,对任何其他载具类型调用此函数均不起作用。
local ret = my_vehicle:BindAnimationBlueprintEventDispatcher(dispatcher_name, callback)

Parameters

TypeParameterDefaultDescription
stringdispatcher_name Required parameter 事件分发器名称
functioncallback Required parameter 要调用的回调函数 with this format

Returns

TypeDescription
function回调函数本身

Slow

CallAnimationBlueprintEvent

调用动画蓝图事件或函数。
客户端返回所有函数返回值。

注:VehicleWheeled 拥有动画蓝图,对任何其他载具类型调用此函数均不起作用。
local ret_01, ret_02, ... = my_vehicle:CallAnimationBlueprintEvent(event_name, arguments...?)

Parameters

TypeParameterDefaultDescription
stringevent_name Required parameter 事件或函数名称
anyarguments...?nil
要传递给该事件的参数序列

Returns

TypeDescription
varargs of any函数的返回值

Optimal

GetAllSkeletalMeshAttached

获取附加到此实体的所有骨骼网格体
local ret = my_vehicle:GetAllSkeletalMeshAttached()

Returns

TypeDescription
table of string键为附加 ID,值为资产路径的表

Optimal

GetAllStaticMeshAttached

获取附加到此实体的所有静态网格体
local ret = my_vehicle:GetAllStaticMeshAttached()

Returns

TypeDescription
table of string键为附加 ID,值为资产路径的表

Slow

GetAnimationBlueprintPropertyValue

直接获取动画蓝图属性/变量的值。

注:VehicleWheeled 拥有动画蓝图,对任何其他载具类型调用此函数将返回 nil
local ret = my_vehicle:GetAnimationBlueprintPropertyValue(property_name)

Parameters

TypeParameterDefaultDescription
stringproperty_name Required parameter No description provided

Returns

TypeDescription
any属性值

See also SetAnimationBlueprintPropertyValue.


Moderate

GetDoors

获取所有配置的门
local ret = my_vehicle:GetDoors()

Returns

TypeDescription
tablewith this format

Optimal

GetMesh

获取资产名称
local asset = my_vehicle:GetMesh()

Returns

TypeDescription
SkeletalMesh Reference资产路径

Optimal

GetPassenger

获取指定座位上的乘客
local passenger = my_vehicle:GetPassenger(seat)

Parameters

TypeParameterDefaultDescription
integerseat Required parameter No description provided

Returns

TypeDescription
Character如果座位上没有乘客则返回 nil

Moderate

GetPassengers

获取所有乘客
local passengers = my_vehicle:GetPassengers()

Returns

TypeDescription
table of Characterpassengers

Optimal

IsEngineStarted

检查引擎是否已启动
local is_started = my_vehicle:IsEngineStarted()

Returns

TypeDescription
booleanis_started

Moderate

PlayAnimation

在此载具上播放动画
my_vehicle:PlayAnimation(animation_path, slot_name?, loop_indefinitely?, blend_in_time?, blend_out_time?, play_rate?, stop_all_montages?)

Parameters

TypeParameterDefaultDescription
Animation Referenceanimation_path Required parameter No description provided
stringslot_name?DefaultSlot
No description provided
booleanloop_indefinitely?false
仅当载具拥有动画蓝图时使用此参数
floatblend_in_time?0.25
仅当载具拥有动画蓝图时使用此参数
floatblend_out_time?0.25
仅当载具拥有动画蓝图时使用此参数
floatplay_rate?1.0
仅当载具拥有动画蓝图时使用此参数
booleanstop_all_montages?false
停止来自同一组的所有正在运行的动画蒙太奇。该参数仅在载具拥有动画蓝图时使用

Optimal

RemoveAllSkeletalMeshesAttached

移除所有已附加的骨骼网格体
my_vehicle:RemoveAllSkeletalMeshesAttached()

Optimal

RemoveAllStaticMeshesAttached

移除所有已附加的静态网格体
my_vehicle:RemoveAllStaticMeshesAttached()

Optimal

RemoveSkeletalMeshAttached

根据自定义 ID 移除此载具上已存在的骨骼网格体(如果存在)
my_vehicle:RemoveSkeletalMeshAttached(id)

Parameters

TypeParameterDefaultDescription
stringid Required parameter 要移除的骨骼网格体的唯一 ID

See also AddSkeletalMeshAttached.


Optimal

RemoveStaticMeshAttached

根据自定义 ID 移除此载具上已存在的静态网格体(如果存在)
my_vehicle:RemoveStaticMeshAttached(id)

Parameters

TypeParameterDefaultDescription
stringid Required parameter 要移除的静态网格体的唯一 ID

See also AddStaticMeshAttached.


Slow

SetAnimationBlueprintPropertyValue

在构造函数中传入的动画蓝图上直接设置其属性/变量的值。

注:VehicleWheeled 拥有动画蓝图,对任何其他载具类型调用此函数均不起作用。
my_vehicle:SetAnimationBlueprintPropertyValue(property_name, value)

Parameters

TypeParameterDefaultDescription
stringproperty_name Required parameter No description provided
anyvalue Required parameter No description provided

See also GetAnimationBlueprintPropertyValue.


Moderate

SetBuoyancyPontoons

设置用于让该实体浮于水面上的球形浮筒,这将覆盖根据网格体边界和质量自动计算出的浮筒。

不传值(或传入空表)可恢复为自动计算的浮筒。

浮筒仅在启用了水体浮力的地图中生效
my_vehicle:SetBuoyancyPontoons(pontoons?)

Parameters

TypeParameterDefaultDescription
tablepontoons?nil
包含浮筒数据的数组,传入 nil 可恢复自动计算的浮筒 with this format

Moderate

SetBuoyancySettings

传入 nil 值将恢复该设置的默认值。

在自动计算浮筒时,修改 buoyancy_coefficient 也会同步重新计算浮筒,因为浮筒半径是由该系数推算出来的。
my_vehicle:SetBuoyancySettings(enabled?, buoyancy_coefficient?, buoyancy_damp?, max_buoyant_force?)

Parameters

TypeParameterDefaultDescription
booleanenabled?true
是否施加浮力
floatbuoyancy_coefficient?0.1
漂浮的程度,越高程度越大
floatbuoyancy_damp?1000
垂直速度的一阶阻尼,用于减少起伏
floatmax_buoyant_force?5000000
向上力的最大限制值,防止较轻的物体被直接弹飞出水面

Optimal

SetCameraArmLength

设置驾驶此载具时摄像机与载具保持的距离(厘米)。

在玩家驾驶载具期间,这将覆盖玩家自身的相机臂长度。设为 0 则改用玩家原本的值(这也是默认设置)。
my_vehicle:SetCameraArmLength(arm_length)

Parameters

TypeParameterDefaultDescription
integerarm_length Required parameter 距离(厘米),或设为 0 以使用玩家自带的值

Optimal

SetCameraOffset

设置载具相机偏移量
my_vehicle:SetCameraOffset(offset)

Parameters

TypeParameterDefaultDescription
Vectoroffset Required parameter No description provided

Optimal

SetDoor

在距离根节点 offset_location 偏移量处添加一个车门,并将角色放置在 seat_location 位置且应用 seat_rotation 旋转角度。
my_vehicle:SetDoor(seat_index, offset_location, seat_location, seat_rotation, trigger_radius, leave_lateral_offset)

Parameters

TypeParameterDefaultDescription
integerseat_index Required parameter No description provided
Vectoroffset_location Required parameter No description provided
Vectorseat_location Required parameter No description provided
Rotatorseat_rotation Required parameter No description provided
integertrigger_radius Required parameter No description provided
integerleave_lateral_offset Required parameter 角色离开载具时将被弹出的位置(例如,左车门为 -150,右车门为 150)

Optimal

SetExplosionSettings

配置当生命值归零时的爆炸设置
my_vehicle:SetExplosionSettings(engine_relative_location, materials_index_burnt_override, materials_index_burnt_invisible)

Parameters

TypeParameterDefaultDescription
Vectorengine_relative_location Required parameter 引擎的相对位置。用于应用粒子和特效。
tablematerials_index_burnt_override Required parameter 爆炸时覆盖为烧毁效果的材质索引列表。留空则作用于所有索引。
tablematerials_index_burnt_invisible Required parameter 爆炸时覆盖为不可见的材质索引列表。留空则作用于所有索引。
Vehicle.SetExplosionSettings Examples
Vehicle Explosion Settings
my_vehicle:SetExplosionSettings(Vector(-50, 0, 0), { 1, 2, 4 }, { 3 })

Optimal

SetStaticMeshAttachedTransform

设置已附加静态网格体的位置和旋转
my_vehicle:SetStaticMeshAttachedTransform(id, relative_location, relative_rotation)

Parameters

TypeParameterDefaultDescription
stringid Required parameter 通过 AddStaticMeshAttached 设置的静态网格体的唯一 ID
Vectorrelative_location Required parameter 新的相对位置
Rotatorrelative_rotation Required parameter 新的相对旋转

See also AddStaticMeshAttached.


Optimal

StopAnimation

停止在此载具上播放的动画蒙太奇
my_vehicle:StopAnimation(animation_asset?)

Parameters

TypeParameterDefaultDescription
Animation Referenceanimation_asset?
留空以停止所有蒙太奇

Optimal

UnbindAnimationBlueprintEventDispatcher

解绑一个动画蓝图事件分发器
my_vehicle:UnbindAnimationBlueprintEventDispatcher(dispatcher_name, callback?)

Parameters

TypeParameterDefaultDescription
stringdispatcher_name Required parameter 事件分发器名称
functioncallback?nil
可选的要解绑的回调函数

🚀 事件

NameDescription
CharacterAttemptEnter当角色尝试进入载具时触发
CharacterAttemptLeave当角色尝试离开载具时触发
CharacterEnter当角色完全进入载具时触发
CharacterLeave当角色完全离开载具时触发
EngineStart引擎启动时触发
EngineStop引擎停止时触发
Hit当载具撞击到某物时触发

CharacterAttemptEnter

当角色尝试进入载具时触发

返回 false 以阻止该行为
<AnyVehicleClass>.Subscribe("CharacterAttemptEnter", function(self, character, seat)
-- CharacterAttemptEnter was called
return true
end)

Arguments

TypeArgumentDescription
Base VehicleselfNo description provided
CharactercharacterNo description provided
integerseat座位索引

CharacterAttemptLeave

当角色尝试离开载具时触发

返回 false 以阻止该行为
<AnyVehicleClass>.Subscribe("CharacterAttemptLeave", function(self, character)
-- CharacterAttemptLeave was called
return true
end)

Arguments

TypeArgumentDescription
Base VehicleselfNo description provided
CharactercharacterNo description provided

CharacterEnter

当角色完全进入载具时触发
<AnyVehicleClass>.Subscribe("CharacterEnter", function(self, character, seat_index)
-- CharacterEnter was called
end)

Arguments

TypeArgumentDescription
Base VehicleselfNo description provided
CharactercharacterNo description provided
integerseat_indexNo description provided

CharacterLeave

当角色完全离开载具时触发
<AnyVehicleClass>.Subscribe("CharacterLeave", function(self, character, seat_index)
-- CharacterLeave was called
end)

Arguments

TypeArgumentDescription
Base VehicleselfNo description provided
CharactercharacterNo description provided
integerseat_indexNo description provided

EngineStart

引擎启动时触发
<AnyVehicleClass>.Subscribe("EngineStart", function(self)
-- EngineStart was called
end)

Arguments

TypeArgumentDescription
Base VehicleselfNo description provided

EngineStop

引擎停止时触发
<AnyVehicleClass>.Subscribe("EngineStop", function(self)
-- EngineStop was called
end)

Arguments

TypeArgumentDescription
Base VehicleselfNo description provided

Hit

当载具撞击到某物时触发
<AnyVehicleClass>.Subscribe("Hit", function(self, impact_force, normal_impulse, impact_location, velocity, other_actor)
-- Hit was called
end)

Arguments

TypeArgumentDescription
Base VehicleselfNo description provided
integerimpact_force按载具重量归一化后的撞击强度
Vectornormal_impulse撞击的冲量方向
Vectorimpact_location撞击在世界 3D 空间中的位置
Vectorvelocity载具撞击瞬间的速度
Base Actor or nilother_actor撞击该载具的另一个 Actor