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

基础 Pawn

所有角色实体的基类。

👪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附加一个静态网格体到此实体
FollowAI:让该角色跟随另一个 Actor
table of stringGetAllSkeletalMeshAttached获取附加到此实体的所有骨骼网格体
table of stringGetAllStaticMeshAttached获取附加到此实体的所有静态网格体
tableGetCapsuleSize获取胶囊体大小
RotatorGetControlRotation获取控制旋转
booleanGetFlyingMode获取是否处于飞行模式
floatGetGravityScale获取重力缩放值
SkeletalMesh ReferenceGetMesh获取基础网格体资产
VectorGetMovingTo获取正在移动去往的位置
Player or nilGetPlayer获取当前控制此实体的玩家
HideBone隐藏此角色的某根骨骼
booleanIsBoneHidden获取某根骨骼是否被隐藏
Jump触发此角色进行跳跃
MoveToAI:让该角色步行移动到指定位置
RemoveAllSkeletalMeshesAttached移除所有已附加的骨骼网格体
RemoveAllStaticMeshesAttached移除所有已附加的静态网格体
RemoveSkeletalMeshAttached根据自定义 ID 移除此实体上已存在的骨骼网格体
RemoveStaticMeshAttached根据自定义 ID 移除此实体上的 StaticMesh(如果存在)
SetAIAvoidanceSettingsAI:配置 AI 移动时使用的 RVO(相互速度障碍物)避让系统
SetBrakingSettings设置此角色的移动制动设置
SetCanCrouch设置此角色是否被允许下蹲和俯卧
SetCanJump设置此角色是否被允许跳跃
SetCapsuleSize设置此角色的胶囊体大小
SetControlRotation设置控制旋转
SetFlyingMode设置飞行模式
SetGravityScale更改重力缩放值
SetHitReactionEnabled设置角色在受到伤害时是否触发受击反应,通过对受损的本地骨骼应用微小的动态布娃娃效果
SetJumpZVelocity设置跳跃的速度
SetMeshSettings配置网格体附加设置和可见性
SetRagdollOnDeathEnabled设置角色死亡时是否进入布娃娃模式。你可以将其设置为 false 以应用自定义死亡动画
SetStaticMeshAttachedTransform设置已附加静态网格体的位置和旋转
StopAnimation停止该角色上的动画蒙太奇
StopMovementAI:停止移动,可选将速度归零
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_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

Follow

AI:让该角色跟随另一个 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.


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

GetCapsuleSize

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

Returns

TypeDescription
tablecapsule_sizes with this format

See also SetCapsuleSize.


Optimal

GetControlRotation

获取控制旋转
local control_rotation = my_pawn:GetControlRotation()

Returns

TypeDescription
Rotatorcontrol_rotation

See also SetControlRotation.


Optimal

GetFlyingMode

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

Returns

TypeDescription
booleanflying_mode

See also SetFlyingMode.


Optimal

GetGravityScale

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

Returns

TypeDescription
floatgravity_scale

See also SetGravityScale.


Optimal

GetMesh

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

Returns

TypeDescription
SkeletalMesh Referenceskeletal_mesh_asset

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 nilpossesser

See also Possess, UnPossess.


Optimal

HideBone

隐藏此角色的某根骨骼
my_pawn:HideBone(bone_name)

Parameters

TypeParameterDefaultDescription
stringbone_name Required parameter 要隐藏的骨骼

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

触发此角色进行跳跃
my_pawn:Jump()

Optimal

MoveTo

AI:让该角色步行移动到指定位置

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

Parameters

TypeParameterDefaultDescription
Vectorlocation Required parameter No description provided
floatacceptance_radius?50
No description provided

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

SetBrakingSettings

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

Parameters

TypeParameterDefaultDescription
floatground_friction?2
No description provided
floatbraking_friction_factor?2
No description provided
integerbraking_walking?96
No description provided
integerbraking_flying?3000
No description provided
integerbraking_swimming?10
No description provided
integerbraking_falling?0
No description provided

Optimal

SetCanCrouch

设置此角色是否被允许下蹲和俯卧
my_pawn:SetCanCrouch(can_crouch)

Parameters

TypeParameterDefaultDescription
booleancan_crouch Required parameter No description provided

Optimal

SetCanJump

设置此角色是否被允许跳跃
my_pawn:SetCanJump(can_jump)

Parameters

TypeParameterDefaultDescription
booleancan_jump Required parameter No description provided

Optimal

SetCapsuleSize

设置此角色的胶囊体大小(将影响相机位置以及角色的碰撞判定)
🆕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

设置控制旋转
my_pawn:SetControlRotation(control_rotation)

Parameters

TypeParameterDefaultDescription
Rotatorcontrol_rotation Required parameter No description provided

See also GetControlRotation.


Optimal

SetFlyingMode

设置飞行模式
my_pawn:SetFlyingMode(flying_mode)

Parameters

TypeParameterDefaultDescription
booleanflying_mode Required parameter No description provided

See also GetFlyingMode.


Optimal

SetGravityScale

更改此角色的重力缩放值(可以为负数)
my_pawn:SetGravityScale(gravity_scale)

Parameters

TypeParameterDefaultDescription
floatgravity_scale Required parameter No description provided

See also GetGravityScale.


Optimal

SetHitReactionEnabled

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

Parameters

TypeParameterDefaultDescription
booleanis_enabled Required parameter No description provided

Moderate

SetJumpZVelocity

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

Parameters

TypeParameterDefaultDescription
integerjump_z_velocity Required parameter 默认值为 450

Optimal

SetMeshSettings

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

Parameters

TypeParameterDefaultDescription
Vectorrelative_location?Vector(0, 0, 0)
No description provided
Rotatorrelative_rotation?Rotator(0, -90, 0)
No description provided
boolis_visible?true
网格体是否可见(在使用子网格体的重定向器时很有用)

Optimal

SetRagdollOnDeathEnabled

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

Parameters

TypeParameterDefaultDescription
booleanis_enabled Required parameter No description provided

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

StopAnimation

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

Parameters

TypeParameterDefaultDescription
Animation Referenceanimation_asset Required parameter No description provided

Optimal

StopMovement

AI:停止移动,可选将速度归零(非 AI 也会停止)

触发事件 MoveComplete
my_pawn:StopMovement(stops_velocity?)

Parameters

TypeParameterDefaultDescription
booleanstops_velocity?false
同时停止 Pawn 的当前速度

See also Follow, MoveTo, GetMovingTo, MoveComplete.


Optimal

UnHideBone

取消隐藏此角色的某根骨骼
my_pawn:UnHideBone(bone_name)

Parameters

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

See also HideBone, IsBoneHidden.

🚀 事件

NameDescription
AnimationBeginNotify当动画蒙太奇通知开始时
AnimationEndNotify当动画蒙太奇通知结束时
MoveComplete当 AI 到达目的地或失败时调用
Possess当角色被玩家控制时
UnPossess当角色被玩家取消控制时

AnimationBeginNotify

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

Arguments

TypeArgumentDescription
CharacterselfNo description provided
stringnotify_nameNo description provided
stringanimation_nameNo description provided
numbertrigger_begin_timeNo description provided
numbertrigger_end_timeNo description provided

AnimationEndNotify

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

Arguments

TypeArgumentDescription
CharacterselfNo description provided
stringnotify_nameNo description provided
stringanimation_nameNo description provided
numbertrigger_begin_timeNo description provided
numbertrigger_end_timeNo description provided

MoveComplete

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

Arguments

TypeArgumentDescription
Base PawnselfNo description provided
booleansucceededNo description provided

See also StopMovement, MoveTo, Follow, GetMovingTo.


Possess

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

Arguments

TypeArgumentDescription
Base PawnselfNo description provided
PlayerplayerNo description provided

See also UnPossess, GetPlayer.


UnPossess

当角色被玩家取消控制时
<AnyPawnClass>.Subscribe("UnPossess", function(self, old_player)
-- UnPossess was called
end)

Arguments

TypeArgumentDescription
Base PawnselfNo description provided
Playerold_playerNo description provided

See also Possess, GetPlayer.