跳至正文
版本:bleeding-edge 🩸

基础 Pawn

所有 Pawn 实体(Character 和 CharacterSimple)的基类。

👪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: Character, CharacterSimple.

🦠 函数​

ReturnsNameDescription
AddSkeletalMeshAttached附加一个骨骼网格体作为该实体的骨骼主姿态
AddStaticMeshAttached附加一个静态网格体到此实体
ClearMorphTargets清除此 Pawn 的网格体上设置的所有变形目标
FollowAI:使此 Pawn 跟随另一个 Actor
table of stringGetAllMorphTargetNames返回一个包含所有可用变形目标的表
table of stringGetAllSkeletalMeshAttached获取附加到此实体的所有骨骼网格体
table of stringGetAllStaticMeshAttached获取附加到此实体的所有静态网格体
booleanGetCanCrouch获取此 Pawn 是否允许下蹲
booleanGetCanJump获取此 Pawn 是否允许跳跃
tableGetCapsuleSize获取胶囊体大小
RotatorGetControlRotation获取控制旋转,即此 Pawn 看向或瞄准的方向
booleanGetFlyingMode获取是否处于飞行模式
floatGetGravityScale获取重力缩放值
integerGetJumpZVelocity获取跳跃时的初始垂直速度,决定跳跃高度
SkeletalMesh ReferenceGetMesh获取基础网格体资产
floatGetMorphTarget返回指定变形目标的值
VectorGetMovingTo获取正在移动去往的位置
Player or nilGetPlayer获取当前控制此实体的玩家
integerGetTeam获取此 Pawn 的队伍
HideBone隐藏此 Pawn 的某个骨骼
booleanIsBoneHidden获取某根骨骼是否被隐藏
Jump触发此 Pawn 跳跃
MoveToAI:使此 Pawn 行走至指定位置
RemoveAllSkeletalMeshesAttached移除所有已附加的骨骼网格体
RemoveAllStaticMeshesAttached移除所有已附加的静态网格体
RemoveSkeletalMeshAttached根据自定义 ID 移除此实体上已存在的骨骼网格体
RemoveStaticMeshAttached根据自定义 ID 移除此实体上的 StaticMesh(如果存在)
SetAIAvoidanceSettingsAI:配置 AI 移动时使用的 RVO(相互速度障碍物)避让系统
SetAIStopWithBrakingAI:设置 AI 在完成移动时是制动减速停止,而不是立即停止
SetBrakingSettings设置此 Pawn 的移动制动设置
SetCanCrouch设置此 Pawn 是否允许下蹲
SetCanJump设置此 Pawn 是否允许跳跃
SetCapsuleSize设置此 Pawn 的胶囊体尺寸
SetControlRotation设置控制旋转,即此 Pawn 看向或瞄准的方向
SetFlyingMode启用或禁用飞行模式(消除重力并允许向所有方向移动)
SetGravityScale更改重力缩放值
SetHitReactionEnabled设置角色在受到伤害时是否触发受击反应,通过对受损的本地骨骼应用微小的动态布娃娃效果
SetJumpZVelocity设置跳跃的速度
SetMeshSettings配置网格体附加设置和可见性
SetMorphTarget设置变形目标的值
SetRagdollOnDeathEnabled设置角色死亡时是否进入布娃娃模式。你可以将其设置为 false 以应用自定义死亡动画
SetStaticMeshAttachedTransform设置已附加静态网格体的位置和旋转
SetTeam设置团队,将禁用对同一团队成员的伤害
StopAnimation停止该角色上的动画蒙太奇
StopMovementAI:停止 MoveTo 与 Follow 导航
UnHideBone取消隐藏此 Pawn 的某个骨骼

Slow

AddSkeletalMeshAttached​

将骨骼网格体作为主姿态附加到此实体。

生成一个骨骼网格体并将其附加到此实体,该骨骼网格体必须使用与此 Actor 网格体相同的骨骼,并会跟随其所有动画。使用自定义 ID,以便之后移除或自定义它
🆕Updated Function
This method was recently updated in ver. 1.144. See the Compatibility Versions page for more information.
my_pawn: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?
要附加到的骨骼插槽。传入空字符串以附加到根组件(即胶囊体)。传入 'root' 以附加到主骨骼网格体组件的根骨骼
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_pawn: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

ClearMorphTargets​

清除此 Pawn 的网格体上设置的所有变形目标
my_pawn:ClearMorphTargets()

See also SetMorphTarget, GetMorphTarget, GetAllMorphTargetNames.


Optimal

Follow​

AI:使此 Pawn 跟随另一个 Actor。

触发事件 MoveComplete
my_pawn:Follow(actor, acceptance_radius?, stop_on_succeed?, stop_on_fail?, update_rate?)

Parameters

TypeParameterDefaultDescription
Base Actoractor Required parameter 要跟随的 Actor
floatacceptance_radius?50
判定为成功的半径范围
booleanstop_on_succeed?false
到达目标时是否停止
booleanstop_on_fail?false
未能到达目标时是否停止
floatupdate_rate?0.25
重新计算 AI 路径的频率

See also StopMovement, MoveTo, GetMovingTo, MoveComplete.


Optimal

GetAllMorphTargetNames​

返回一个包含所有可用变形目标的表。

如果网格体不是骨骼网格体,则返回空表(CharacterSimple 可能使用静态网格体)
local ret = my_pawn:GetAllMorphTargetNames()

Returns

TypeDescription
table of string包含所有可用变形目标的表

See also SetMorphTarget, GetMorphTarget, ClearMorphTargets.


Moderate

GetAllSkeletalMeshAttached​

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

Returns

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

Moderate

GetAllStaticMeshAttached​

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

Returns

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

Optimal

GetCanCrouch​

获取此 Pawn 是否允许下蹲
local can_crouch = my_pawn:GetCanCrouch()

Returns

TypeDescription
boolean此 Pawn 是否允许下蹲

See also SetCanCrouch.


Optimal

GetCanJump​

获取此 Pawn 是否允许跳跃
local can_jump = my_pawn:GetCanJump()

Returns

TypeDescription
boolean此 Pawn 是否允许跳跃

See also SetCanJump.


Optimal

GetCapsuleSize​

获取胶囊体大小
local capsule_sizes = my_pawn:GetCapsuleSize()

Returns

TypeDescription
table胶囊体尺寸 with this format

See also SetCapsuleSize.


Optimal

GetControlRotation​

获取控制旋转,即此 Pawn 看向或瞄准的方向
local control_rotation = my_pawn:GetControlRotation()

Returns

TypeDescription
Rotator控制旋转

See also SetControlRotation.


Optimal

GetFlyingMode​

获取是否处于飞行模式
local flying_mode = my_pawn:GetFlyingMode()

Returns

TypeDescription
boolean是否处于飞行模式

See also SetFlyingMode.


Optimal

GetGravityScale​

获取重力缩放值
local gravity_scale = my_pawn:GetGravityScale()

Returns

TypeDescription
float重力缩放比例

See also SetGravityScale.


Optimal

GetJumpZVelocity​

获取跳跃时的初始垂直速度,决定跳跃高度
local jump_z_velocity = my_pawn:GetJumpZVelocity()

Returns

TypeDescription
integer跳跃 Z 轴速度

See also SetJumpZVelocity.


Optimal

GetMesh​

获取基础网格体资产
local skeletal_mesh_asset = my_pawn:GetMesh()

Returns

TypeDescription
SkeletalMesh Reference基础网格体资产

Optimal

GetMorphTarget​

返回指定变形目标的值
local value = my_pawn:GetMorphTarget(name)

Parameters

TypeParameterDefaultDescription
stringname Required parameter 变形目标名称

Returns

TypeDescription
float变形目标的值

See also SetMorphTarget, ClearMorphTargets, GetAllMorphTargetNames.


Optimal

GetMovingTo​

获取正在移动去往的位置
local location = my_pawn:GetMovingTo()

Returns

TypeDescription
Vector正在移动去往的位置,如果未移动则返回 Vector(0, 0, 0)

Optimal

GetPlayer​

获取当前控制此实体的玩家
local possesser = my_pawn:GetPlayer()

Returns

TypeDescription
Player or nil控制中的玩家

See also Possess, UnPossess.


Optimal

GetTeam​

获取此 Pawn 的队伍
local team = my_pawn:GetTeam()

Returns

TypeDescription
integer队伍编号,0 表示无队伍

See also SetTeam.


Optimal

HideBone​

隐藏此 Pawn 的某个骨骼。

请查阅 骨骼名称列表
my_pawn:HideBone(bone_name?)

Parameters

TypeParameterDefaultDescription
stringbone_name?
要隐藏的骨骼

See also UnHideBone, IsBoneHidden.


Optimal

IsBoneHidden​

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

Parameters

TypeParameterDefaultDescription
stringbone_name Required parameter 要检查的骨骼

Returns

TypeDescription
boolean骨骼是否被隐藏

See also UnHideBone, HideBone.


Optimal

Jump​

触发此 Pawn 跳跃
my_pawn:Jump()

Optimal

MoveTo​

AI:使此 Pawn 走向该位置。

在飞行模式(参见 SetFlyingMode)下,它会沿直线飞往该处而不是沿导航网格体移动,因此该位置可以位于空中

触发事件 MoveComplete
my_pawn:MoveTo(location, acceptance_radius?)

Parameters

TypeParameterDefaultDescription
Vectorlocation Required parameter 目的地
floatacceptance_radius?50
距离目的地多近会被判定为到达

See also StopMovement, Follow, GetMovingTo, MoveComplete.


Optimal

RemoveAllSkeletalMeshesAttached​

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

Optimal

RemoveAllStaticMeshesAttached​

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

Optimal

RemoveSkeletalMeshAttached​

根据自定义 ID 移除此实体上已存在的骨骼网格体
my_pawn:RemoveSkeletalMeshAttached(id)

Parameters

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

See also AddSkeletalMeshAttached.


Optimal

RemoveStaticMeshAttached​

根据自定义 ID 移除此实体上的 StaticMesh(如果存在)
my_pawn:RemoveStaticMeshAttached(id)

Parameters

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

See also AddStaticMeshAttached.


Optimal

SetAIAvoidanceSettings​

AI:配置 AI 移动时使用的 RVO(相互速度障碍物)避让系统
my_pawn:SetAIAvoidanceSettings(enabled, avoidance_consideration_radius?)

Parameters

TypeParameterDefaultDescription
booleanenabled Required parameter 是否启用 RVO 避让
integeravoidance_consideration_radius?300
用于确定避让距离的圆半径

Optimal

SetAIStopWithBraking​

AI:设置 AI 在完成移动时是制动减速停止,而不是立即停止。

启用后,Pawn 在到达目的地时会保留其速度,并使用自身的制动设置减速(参见 Character:SetBrakingSettings 和 CharacterSimple:SetBrakingSettings),因此可能会在略微超过接受半径处停下。默认禁用
my_pawn:SetAIStopWithBraking(enabled)

Parameters

TypeParameterDefaultDescription
booleanenabled Required parameter 是否制动减速停止

Optimal

SetBrakingSettings​

设置此 Pawn 的移动制动设置
my_pawn:SetBrakingSettings(ground_friction?, braking_friction_factor?, braking_walking?, braking_flying?, braking_swimming?, braking_falling?)

Parameters

TypeParameterDefaultDescription
floatground_friction?2
在地面行走时施加的摩擦力
floatbraking_friction_factor?2
制动时施加摩擦力的系数
integerbraking_walking?96
无输入行走时的减速度
integerbraking_flying?3000
无输入飞行时的减速度
integerbraking_swimming?10
无输入游泳时的减速度
integerbraking_falling?0
无输入下落时的水平减速度

Optimal

SetCanCrouch​

设置此 Pawn 是否允许下蹲
my_pawn:SetCanCrouch(can_crouch)

Parameters

TypeParameterDefaultDescription
booleancan_crouch Required parameter 此 Pawn 是否允许下蹲

See also GetCanCrouch.


Optimal

SetCanJump​

设置此 Pawn 是否允许跳跃
my_pawn:SetCanJump(can_jump)

Parameters

TypeParameterDefaultDescription
booleancan_jump Required parameter 此 Pawn 是否允许跳跃

See also GetCanJump.


Optimal

SetCapsuleSize​

设置此 Pawn 的胶囊体大小。

它会影响相机位置和 Pawn 的碰撞
🆕Updated Function
This method was recently updated in ver. 1.144. See the Compatibility Versions page for more information.
my_pawn:SetCapsuleSize(radius?, half_height?, crouched_half_height?)

Parameters

TypeParameterDefaultDescription
integerradius?0
传入 0 以根据网格体边界自动计算半径
integerhalf_height?0
传入 0 以根据网格体边界自动计算半高
integercrouched_half_height?0
传入 0 以根据网格体边界自动计算下蹲半高

See also GetCapsuleSize.


Optimal

SetControlRotation​

设置控制旋转,即此 Pawn 看向或瞄准的方向
my_pawn:SetControlRotation(control_rotation)

Parameters

TypeParameterDefaultDescription
Rotatorcontrol_rotation Required parameter 新的控制旋转

See also GetControlRotation.


Optimal

SetFlyingMode​

启用或禁用飞行模式(消除重力并允许向所有方向移动)
my_pawn:SetFlyingMode(flying_mode)

Parameters

TypeParameterDefaultDescription
booleanflying_mode Required parameter 是否启用飞行模式

See also GetFlyingMode.


Optimal

SetGravityScale​

更改重力缩放。

它可以是负值
my_pawn:SetGravityScale(gravity_scale)

Parameters

TypeParameterDefaultDescription
floatgravity_scale Required parameter 新的重力缩放比例

See also GetGravityScale.


Optimal

SetHitReactionEnabled​

设置角色在受到伤害时是否触发受击反应,通过对受损的本地骨骼应用微小的动态布娃娃效果
my_pawn:SetHitReactionEnabled(is_enabled)

Parameters

TypeParameterDefaultDescription
booleanis_enabled Required parameter 角色受到伤害时是否会在受损的局部骨骼上应用微小的动态布娃娃效果作为受击反应

Moderate

SetJumpZVelocity​

设置跳跃的速度
my_pawn:SetJumpZVelocity(jump_z_velocity)

Parameters

TypeParameterDefaultDescription
integerjump_z_velocity Required parameter 默认值为 420

See also GetJumpZVelocity.


Optimal

SetMeshSettings​

配置网格体附加设置和可见性
my_pawn:SetMeshSettings(relative_location?, relative_rotation?, is_visible?)

Parameters

TypeParameterDefaultDescription
Vectorrelative_location?Vector(0, 0, 0)
网格体相对于胶囊体的位置
Rotatorrelative_rotation?Rotator(0, -90, 0)
网格体相对于胶囊体的旋转
booleanis_visible?true
网格体是否可见(在使用子网格体的重定向器时很有用)

Moderate

SetMorphTarget​

设置变形目标的值
my_pawn:SetMorphTarget(name, value)

Parameters

TypeParameterDefaultDescription
stringname Required parameter 变形目标名称
floatvalue Required parameter 变形目标的权重,通常在 0 到 1 之间

See also GetMorphTarget, ClearMorphTargets, GetAllMorphTargetNames.


Optimal

SetRagdollOnDeathEnabled​

设置角色死亡时是否进入布娃娃模式。你可以将其设置为 false 以应用自定义死亡动画
my_pawn:SetRagdollOnDeathEnabled(is_enabled)

Parameters

TypeParameterDefaultDescription
booleanis_enabled Required parameter 角色死亡时是否进入布娃娃模式。可以设为 false 以应用自定义死亡动画

Moderate

SetStaticMeshAttachedTransform​

设置已附加静态网格体的位置和旋转
my_pawn: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

SetTeam​

设置团队,将禁用对同一团队成员的伤害
my_pawn:SetTeam(team)

Parameters

TypeParameterDefaultDescription
integerteam Required parameter 0 为中立且为默认值

See also GetTeam.


Optimal

StopAnimation​

停止该角色上的动画蒙太奇
my_pawn:StopAnimation(animation_asset)

Parameters

TypeParameterDefaultDescription
Animation Referenceanimation_asset Required parameter 要停止的动画资产

Optimal

StopMovement​

AI:停止 MoveTo 和 Follow 导航。

触发 MoveComplete 事件
my_pawn:StopMovement()

See also Follow, MoveTo, GetMovingTo, MoveComplete.


Optimal

UnHideBone​

取消隐藏此 Pawn 的某个骨骼。

请查阅 骨骼名称列表
my_pawn:UnHideBone(bone_name)

Parameters

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

See also HideBone, IsBoneHidden.

🚀 事件​

NameDescription
AnimationBeginNotify当动画蒙太奇通知开始时
AnimationEndNotify当动画蒙太奇通知结束时
MoveComplete当 AI 到达目的地或失败时调用
Possess当此 Pawn 被玩家控制时触发
UnPossess当玩家解除对此 Pawn 的控制时触发

AnimationBeginNotify​

当动画蒙太奇通知开始时
<AnyPawnClass>.Subscribe("AnimationBeginNotify", function(self, notify_name, animation_name, trigger_begin_time, trigger_end_time)
-- AnimationBeginNotify was called
end)

Arguments

TypeArgumentDescription
Base Pawnself触发该事件的 Pawn
stringnotify_name动画通知的名称
stringanimation_name触发该通知的动画蒙太奇名称
numbertrigger_begin_time通知开始时在动画中的时间(秒)
numbertrigger_end_time通知结束时在动画中的时间(秒)

AnimationEndNotify​

当动画蒙太奇通知结束时
<AnyPawnClass>.Subscribe("AnimationEndNotify", function(self, notify_name, animation_name, trigger_begin_time, trigger_end_time)
-- AnimationEndNotify was called
end)

Arguments

TypeArgumentDescription
Base Pawnself触发该事件的 Pawn
stringnotify_name动画通知的名称
stringanimation_name触发该通知的动画蒙太奇名称
numbertrigger_begin_time通知开始时在动画中的时间(秒)
numbertrigger_end_time通知结束时在动画中的时间(秒)

MoveComplete​

当 AI 到达目的地或失败时调用
<AnyPawnClass>.Subscribe("MoveComplete", function(self, succeeded)
-- MoveComplete was called
end)

Arguments

TypeArgumentDescription
Base Pawnself触发该事件的 Pawn
booleansucceeded是否已到达目的地

See also StopMovement, MoveTo, Follow, GetMovingTo.


Possess​

当此 Pawn 被玩家控制时触发
<AnyPawnClass>.Subscribe("Possess", function(self, player)
-- Possess was called
end)

Arguments

TypeArgumentDescription
Base Pawnself触发该事件的 Pawn
Playerplayer目标玩家

See also UnPossess, GetPlayer.


UnPossess​

当玩家解除对此 Pawn 的控制时触发
<AnyPawnClass>.Subscribe("UnPossess", function(self, old_player)
-- UnPossess was called
end)

Arguments

TypeArgumentDescription
Base Pawnself触发该事件的 Pawn
Playerold_player此前控制此 Pawn 的玩家

See also Possess, GetPlayer.