跳至正文
版本:最新版 - a1.148.0 ⚖️

基础载具

所有载具实体的基类。

👪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附加一个静态网格体到此实体
table of stringGetAllSkeletalMeshAttached获取附加到此实体的所有骨骼网格体
table of stringGetAllStaticMeshAttached获取附加到此实体的所有静态网格体
tableGetDoors获取所有配置的门
SkeletalMesh ReferenceGetMesh获取资产名称
CharacterGetPassenger获取指定座位上的乘客
table of CharacterGetPassengers获取所有乘客
HideBone隐藏此载具的某根骨骼
booleanIsBoneHidden获取某根骨骼是否被隐藏
PlayAnimation在此载具上播放动画
RemoveAllSkeletalMeshesAttached移除所有已附加的骨骼网格体
RemoveAllStaticMeshesAttached移除所有已附加的静态网格体
RemoveSkeletalMeshAttached根据自定义 ID 移除此载具上已存在的骨骼网格体(如果存在)
RemoveStaticMeshAttached根据自定义 ID 移除此载具上已存在的静态网格体(如果存在)
SetDoor为载具添加一个车门
SetExplosionSettings配置当生命值归零时的爆炸设置
SetStaticMeshAttachedTransform设置已附加静态网格体的位置和旋转
UnHideBone取消隐藏此载具的某根骨骼

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.


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,值为资产路径的表

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

HideBone

隐藏此载具的某根骨骼
my_vehicle:HideBone(bone_name)

Parameters

TypeParameterDefaultDescription
stringbone_name Required parameter 要隐藏的骨骼

See also UnHideBone, IsBoneHidden.


Optimal

IsBoneHidden

获取某根骨骼是否被隐藏
local is_hidden = my_vehicle:IsBoneHidden(bone_name)

Parameters

TypeParameterDefaultDescription
stringbone_name Required parameter 要检查的骨骼

Returns

TypeDescription
boolean骨骼是否被隐藏

See also UnHideBone, HideBone.


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.


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

UnHideBone

取消隐藏此载具的某根骨骼
my_vehicle:UnHideBone(bone_name)

Parameters

TypeParameterDefaultDescription
stringbone_name Required parameter 要取消隐藏的骨骼

See also HideBone, IsBoneHidden.

🚀 事件

NameDescription
CharacterAttemptEnter当角色尝试进入载具时触发
CharacterAttemptLeave当角色尝试离开载具时触发
CharacterEnter当角色完全进入载具时触发
CharacterLeave当角色完全离开载具时触发
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

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