跳至正文
版本:bleeding-edge 🩸

🧑‍🦲 CharacterSimple

CharacterSimple 是一个更简单的 Character 实现,具备基础的移动功能。旨在用于自定义 NPC 或基础的 Pawn。

💂Authority
This class can be spawned on both 🟧 Client and 🟦 Server side.
🔁Network Authority Distribution
This class have the Network Authority distribution enabled and automatically handled by the server. You can override the Network Authority or disable it from automatically distributing.
👪Inheritance
This class shares methods and events from Base Entity, Base Actor, Base Paintable, Base Damageable, Base Pawn.
🧑‍💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

🎒 示例

Server/Index.lua
-- Spawns a Stack-O-Bot Character
local stack_o_bot = CharacterSimple(Vector(100, 0, 100), Rotator(0, 0, 0), "nanos-world::SK_StackOBot", "nanos-world::ABP_StackOBot")
stack_o_bot:SetSpeedSettings(275, 150)

🛠 构造函数

Default Constructor

No description provided

local my_charactersimple = CharacterSimple(location, rotation, mesh, custom_animation_blueprint?, collision_type?, gravity_enabled?, defer_spawn?)

Parameters

TypeNameDefaultDescription
Vectorlocation Required parameter No description provided
Rotatorrotation Required parameter No description provided
SkeletalMesh Reference or StaticMesh Referencemesh Required parameter No description provided
Blueprint Referencecustom_animation_blueprintNo description provided
CollisionTypecollision_typeCollisionType.AutoNo description provided
booleangravity_enabledtrueNo description provided
booleandefer_spawnfalse传入 true 以避免立即将该实体发送给客户端,从而在你想要通过设置多个配置来调整它时提高性能。最后必须调用 FinishSpawn()

🗿 静态函数

Inherited Entity Static Functions
CharacterSimple inherits from Base Entity Class, sharing it's methods and functions:
Base Entityscripting-reference/classes/base-classes/entity
ReturnsNameDescription
table of Base EntityGetAll返回一个包含调用此方法的类中所有实体的表
Base EntityGetByIndex返回该类中指定索引处的特定实体
integerGetCount返回该类当前存在的实体数量
table of tableGetInheritedClasses获取使用 继承系统 创建的、直接继承自该类的所有子类列表
iteratorGetPairs返回一个包含该类所有实体的迭代器,用于 pairs() 循环
table or nilGetParentClass如果该类是使用 继承系统 创建的,则获取其父类
tableInherit使用 继承系统 继承此类
booleanIsChildOf如果该类是使用 继承系统 创建的,检查此类是否为另一个类的子类
functionSubscribe为该类的所有实体订阅一个 事件
functionSubscribeRemote订阅从服务器调用的自定义远程事件
Unsubscribe退订此包内该类中此 事件 的所有回调,或者仅取消传入的特定回调

This class doesn't have own static functions.

🦠 函数

Inherited Entity Functions
CharacterSimple inherits from Base Entity Class, sharing it's methods and functions:
Base Entityscripting-reference/classes/base-classes/entity
ReturnsNameDescription
BroadcastRemoteEvent直接在此实体上向所有玩家调用自定义远程事件
BroadcastRemoteInRadiusEvent直接针对此实体调用自定义远程事件,并将该事件传递给半径范围内的所有玩家
CallRemoteEvent直接在此实体上向特定玩家调用自定义远程事件
CallRemoteEvent直接在此实体上调用自定义远程事件
CallRemotePlayersEvent直接在此实体上调用自定义远程事件,并将事件传递给玩家列表
Destroy销毁该实体
FinishSpawn完成生成过程,如果实体是通过 defer_spawn 生成的,则将实体发送给客户端
table of stringGetAllValuesKeys获取所有值键的列表
tableGetClass获取该实体的类
integerGetID获取该实体的全网通用网络 ID(在客户端和服务器上相同)
anyGetValue获取此实体上存储在给定键处的
booleanHasAuthorityGets if the local context has authority over this Entity (true if spawned by the client, false if spawned by the server)
booleanIsA递归检查此实体是否继承自某个类
booleanIsBeingDestroyed如果该实体正在被销毁,则返回 true
booleanIsValid如果该实体有效(即未被销毁且指向一个有效的实体),则返回 true
SetValue在此实体中设置一个
functionSubscribe在这个特定实体上订阅一个事件
functionSubscribeRemote在这个特定实体上订阅一个从服务器调用的自定义远程事件
Unsubscribe退订此包内该实体中此 事件 的所有回调,或者仅取消传入的特定回调
Inherited Actor Functions
CharacterSimple inherits from Base Actor Class, sharing it's methods and functions:
Base Actorscripting-reference/classes/base-classes/actor
ReturnsNameDescription
AddActorTag向该 Actor 添加一个虚幻 Actor 标签
AddAngularImpulse向该 Actor 添加角冲量。适用于单次瞬间爆发
AddImpulse向该 Actor 添加冲量。适用于单次瞬间爆发
booleanAttachTo将该 Actor 附加到任何其他 Actor 上,可选择附加在特定骨骼处
Detach将该 Actor 从其附加的 Actor 上分离
table of stringGetActorTags获取该 Actor 上的所有虚幻 Actor 标签
VectorGetAngularForce获取该 Actor 的角外力(由 SetAngularForce() 设置)
table of Base ActorGetAttachedEntities获取附加到该 Actor 的所有 Actor
Base Actor or nilGetAttachedTo获取该 Actor 所附加到的父级 Actor
tableGetBounds获取该 Actor 的边界范围
CollisionTypeGetCollision获取该 Actor 的碰撞类型
integerGetDimension获取该 Actor 的维度
floatGetDistanceFromCamera获取该 Actor 距离相机的距离
VectorGetForce获取该 Actor 的持续外力(由 SetForce() 设置)
VectorGetLocation获取该 Actor 在游戏世界中的位置
Player or nilGetNetworkAuthority获取该 Actor 的网络主控玩家
VectorGetRelativeLocation如果该 Actor 已附加,获取其相对位置
RotatorGetRelativeRotation如果该 Actor 已附加,获取其相对旋转
RotatorGetRotation获取该 Actor 在游戏世界中的角度值
VectorGetScale获取该 Actor 的缩放比例
floatGetScreenPercentage获取该 Actor 在屏幕中所占尺寸的百分比
tableGetSocketTransform在给定骨骼或插槽名称的情况下,获取世界空间中的插槽变换
VectorGetVelocity获取该 Actor 当前的速度
booleanHasNetworkAuthority如果本地玩家当前是该 Actor 的网络主控(Network Authority),则返回 true
booleanIsGravityEnabled如果该 Actor 启用了重力,则返回 true
booleanIsInWater如果该 Actor 处于水中,则返回 true
booleanIsNetworkDistributed如果该 Actor 当前处于网络分配状态,则返回 true
booleanIsVisible如果该 Actor 可见,则返回 true
RemoveActorTag从该 Actor 中移除一个虚幻 Actor 标签
RotateTo在一定时间内平滑旋转该 Actor 到指定角度
SetAngularForce向该 Actor 添加一个永久的角外力,设为 Vector(0, 0, 0) 可以取消
SetCastShadow设置该 Actor 是否投射阴影
SetCollision设置该 Actor 的碰撞类型
SetDimension设置该 Actor 的维度
SetDistanceOptimizationMultiplier设置此 Actor 的距离优化系数
SetForce向该 Actor 添加一个永久的外力,设为 Vector(0, 0, 0) 可以取消
SetGravityEnabled设置该 Actor 是否启用重力
SetHighlightEnabled设置该 Actor 是否启用高亮显示,以及使用哪个高亮索引值
SetLifeSpan设置该 Actor 被销毁前的生存时间(秒)。经过这段时间后,Actor 将被自动销毁。
SetLocation设置该 Actor 在游戏世界中的位置
SetNetworkAuthority设置某个玩家拥有此 Actor 的网络主控
SetNetworkAuthorityAutoDistributed设置该 Actor 是否在玩家之间自动分配网络主控
SetOutlineEnabled设置该 Actor 是否启用轮廓线描边,以及使用哪个轮廓线索引值
SetRelativeLocation在本地空间中设置该 Actor 的相对位置(仅在此 Actor 已附加时生效)
SetRelativeRotation在本地空间中设置该 Actor 的相对旋转(仅在此 Actor 已附加时生效)
SetRenderCullDistance设置该 Actor 的渲染剔除距离
SetRotation设置该 Actor 在游戏世界中的旋转
SetScale设置该 Actor 的缩放比例
SetVisibility设置该 Actor 是否可见
TranslateTo在一定时间内平滑地将该 Actor 移动到某个位置
booleanWasRecentlyRendered获取该 Actor 最近是否在屏幕上被渲染过
Inherited Paintable Functions
CharacterSimple inherits from Base Paintable Class, sharing it's methods and functions:
Base Paintablescripting-reference/classes/base-classes/paintable
ReturnsNameDescription
ColorGetMaterialColorParameter从该 Actor 的材质中获取 Color 参数
floatGetMaterialScalarParameter从该 Actor 的材质中获取 Scalar 参数
stringGetMaterialTextureParameter从该 Actor 的材质中获取 Texture 参数
VectorGetMaterialVectorParameter从该 Actor 的材质中获取 Vector 参数
ResetMaterial将指定索引处的材质重置为原始材质
SetMaterial设置该 Actor 指定索引处的材质
SetMaterialColorParameter设置该 Actor 材质中的 Color 参数
SetMaterialFromCanvas将该 Actor 指定索引处的材质设为 Canvas 对象
SetMaterialFromSceneCapture将该 Actor 指定索引处的材质设为 SceneCapture 对象
SetMaterialFromWebUI将该 Actor 指定索引处的材质设为 WebUI 对象
SetMaterialScalarParameter设置该 Actor 材质中的 Scalar 参数
SetMaterialTextureParameter将该 Actor 材质中的纹理参数设为一张图像
SetMaterialVectorParameter设置该 Actor 材质中的 Vector 参数
SetPhysicalMaterial使用新的物理材质覆盖该 Actor 的物理材质
Inherited Damageable Functions
CharacterSimple inherits from Base Damageable Class, sharing it's methods and functions:
Base Damageablescripting-reference/classes/base-classes/damageable
ReturnsNameDescription
integerApplyDamage对该实体造成伤害
floatGetDamageMultiplier获取特定骨骼的伤害系数
integerGetHealth获取当前生命值
integerGetMaxHealth获取最大生命值
booleanIsDead返回该实体是否已死亡
RespawnRespawns the Entity, filling its Health and moving it to its Initial Location
SetDamageMultiplier更改该实体在特定骨骼上受到的伤害大小
SetHealth设置该实体的生命值
SetMaxHealth设置该实体的最大生命值
Inherited Pawn Functions
CharacterSimple inherits from Base Pawn Class, sharing it's methods and functions:
Base Pawnscripting-reference/classes/base-classes/pawn
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 移除此实体上已存在的骨骼网格体
RemoveStaticMeshAttachedRemoves, if it exists, a StaticMesh from this entity given its custom ID
SetAIAvoidanceSettingsAI:配置 AI 移动时使用的 RVO(相互速度障碍物)避让系统
SetBrakingSettings设置此角色的移动制动设置
SetCanCrouch设置此角色是否被允许下蹲和俯卧
SetCanJump设置此角色是否被允许跳跃
SetCapsuleSize设置此角色的胶囊体大小
SetControlRotation设置控制旋转
SetFlyingMode设置飞行模式
SetGravityScale更改重力缩放值
SetHitReactionEnabled设置角色在受到伤害时是否触发受击反应,通过对受损的本地骨骼应用微小的动态布娃娃效果
SetJumpZVelocity设置跳跃的速度
SetMeshSettings配置网格体附加设置和可见性
SetRagdollOnDeathEnabled设置角色死亡时是否进入布娃娃模式。你可以将其设为 false 以应用自定义的死亡动画
SetStaticMeshAttachedTransform设置已附加静态网格体的位置和旋转
StopAnimation停止此角色上正在播放的动画蒙太奇
StopMovementAI:停止移动,可选是否同时将速度归零
UnHideBone取消隐藏此角色的某根骨骼
ReturnsNameDescription
functionBindAnimationBlueprintEventDispatcher分配并绑定一个动画蓝图事件分发器
varargs of anyCallAnimationBlueprintEvent调用一个动画蓝图事件或函数
PlayAnimation在此角色上播放动画蒙太奇
SetAirControl设置角色处于空中时允许的移动控制量
SetAnimationBlueprint设置此角色的动画蓝图
SetAnimationBlueprintPropertyValue直接设置动画蓝图的属性/变量值
SetMaxAcceleration设置最大加速度
SetMesh动态更改角色的网格体
SetPawnSettings设置此角色的 Pawn 设置
SetPhysicsAsset设置角色的物理资产
SetRotationSettings设置此角色的旋转设置
SetSpeedSettings设置此角色的速度设置
SetSpringArmSettings设置此角色的弹簧臂设置
UnbindAnimationBlueprintEventDispatcher解绑一个动画蓝图事件分发器

BindAnimationBlueprintEventDispatcher

分配并绑定一个动画蓝图事件分发器
local ret = my_charactersimple:BindAnimationBlueprintEventDispatcher(dispatcher_name, callback)

Parameters

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

Returns

TypeDescription
function回调函数本身

CallAnimationBlueprintEvent

调用一个动画蓝图事件或函数
客户端 返回所有函数返回值
local ret_01, ret_02, ... = my_charactersimple:CallAnimationBlueprintEvent(event_name, arguments...?)

Parameters

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

Returns

TypeDescription
varargs of any函数的返回值

PlayAnimation

在此角色上播放动画蒙太奇
my_charactersimple: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?No description provided
booleanloop_indefinitely?falseNo description provided
floatblend_in_time?0.25No description provided
floatblend_out_time?0.25传入 -1 以禁用自动混出,并使动画永远保持在最后一帧姿态
floatplay_rate?1.0No description provided
booleanstop_all_montages?false停止来自同一组的所有正在播放的蒙太奇

SetAirControl

设置角色处于空中时允许的移动控制量
my_charactersimple:SetAirControl(air_control?, boost_multiplier?, boost_velocity_threshold?)

Parameters

TypeParameterDefaultDescription
floatair_control?0.2下落时,角色可用的横向移动控制量。0 = 无法控制,1 = 在 MaxWalkSpeed 最大速度下完全控制
floatboost_multiplier?512下落时,当横向速度小于 boost_velocity_threshold 时应用于 air_control 的系数。将其设为 0 将禁用空中控制增强。最终结果会被限制在 1 以内
floatboost_velocity_threshold?25下落时,如果横向速度大小小于该值,则 air_control 会乘以 boost_multiplier。将其设为 0 将禁用空中控制增强

SetAnimationBlueprint

设置此角色的动画蓝图
my_charactersimple:SetAnimationBlueprint(custom_animation_blueprint)

Parameters

TypeParameterDefaultDescription
Blueprint Referencecustom_animation_blueprint Required parameter No description provided

SetAnimationBlueprintPropertyValue

直接设置动画蓝图的属性/变量值
my_charactersimple:SetAnimationBlueprintPropertyValue(property_name, value)

Parameters

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

SetMaxAcceleration

设置最大加速度
my_charactersimple:SetMaxAcceleration(acceleration)

Parameters

TypeParameterDefaultDescription
integeracceleration Required parameter 默认值为 2048

SetMesh

动态更改角色的网格体
🆕Updated Function
This method was recently updated in ver. 1.144. See the Compatibility Versions page for more information.
my_charactersimple:SetMesh(mesh_asset)

Parameters

TypeParameterDefaultDescription
SkeletalMesh Reference or StaticMesh Referencemesh_asset Required parameter No description provided

SetPawnSettings

设置此角色的 Pawn 设置
my_charactersimple:SetPawnSettings(use_controller_rotation_pitch, use_controller_rotation_yaw, use_controller_rotation_roll)

Parameters

TypeParameterDefaultDescription
booleanuse_controller_rotation_pitch Required parameter No description provided
booleanuse_controller_rotation_yaw Required parameter No description provided
booleanuse_controller_rotation_roll Required parameter No description provided

SetPhysicsAsset

设置角色的物理资产
my_charactersimple:SetPhysicsAsset(physics_asset)

Parameters

TypeParameterDefaultDescription
Otherphysics_asset Required parameter No description provided

SetRotationSettings

设置此角色的旋转设置
my_charactersimple:SetRotationSettings(rotation_rate, use_controller_desired_rotation, orient_rotation_to_movement)

Parameters

TypeParameterDefaultDescription
Rotatorrotation_rate Required parameter No description provided
booleanuse_controller_desired_rotation Required parameter No description provided
booleanorient_rotation_to_movement Required parameter No description provided

SetSpeedSettings

设置此角色的速度设置
my_charactersimple:SetSpeedSettings(max_walk_speed?, max_walk_speed_crouched?, max_fly_speed?)

Parameters

TypeParameterDefaultDescription
integermax_walk_speed?600No description provided
integermax_walk_speed_crouched?300No description provided
integermax_fly_speed?600No description provided

SetSpringArmSettings

设置此角色的弹簧臂设置
my_charactersimple:SetSpringArmSettings(relative_location?, target_arm_length?, socket_offset?, enable_camera_lag?, camera_lag_speed?, camera_lag_max_distance?)

Parameters

TypeParameterDefaultDescription
Vectorrelative_location?Vector(0, 0, -1)传入 nil 则使用默认值(胶囊体高度 * 1.8)
floattarget_arm_length?300.0No description provided
Vectorsocket_offset?Vector(0, 0, 0)No description provided
booleanenable_camera_lag?trueNo description provided
floatcamera_lag_speed?15.0No description provided
floatcamera_lag_max_distance?1.0No description provided

UnbindAnimationBlueprintEventDispatcher

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

Parameters

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

🚀 事件

Inherited Entity Events
CharacterSimple inherits from Base Entity Class, sharing it's events:
Base Entityscripting-reference/classes/base-classes/entity
NameDescription
ClassRegister当使用 继承系统 注册一个新类时触发
Destroy当实体被销毁时触发
Spawn当实体被生成/创建时触发
ValueChange当实体通过 :SetValue() 改变了值时触发
Inherited Actor Events
CharacterSimple inherits from Base Actor Class, sharing it's events:
Base Actorscripting-reference/classes/base-classes/actor
NameDescription
DimensionChangeTriggered when an Actor changes its dimension
Inherited Damageable Events
CharacterSimple inherits from Base Damageable Class, sharing it's events:
Base Damageablescripting-reference/classes/base-classes/damageable
NameDescription
Death当实体死亡时
HealthChangeWhen Entity has its Health changed, or because took damage or manually set through scripting or respawning
Respawn当实体重生时
TakeDamage当此实体受到伤害时触发
Inherited Pawn Events
CharacterSimple inherits from Base Pawn Class, sharing it's events:
Base Pawnscripting-reference/classes/base-classes/pawn
NameDescription
AnimationBeginNotify当动画蒙太奇通知开始时
AnimationEndNotify当动画蒙太奇通知结束时
MoveCompleteCalled when AI reaches its destination, or when it fails
Possess当角色被玩家控制时
UnPossess当角色被玩家取消控制时
NameDescription
EndCrouch当 Character 停止下蹲时调用
Jump当 Character 刚刚开始跳跃时触发的事件
Land在下落过程中着地时调用
MovementModeChange当角色移动模式发生改变时调用
StartCrouch当角色开始下蹲时调用

EndCrouch

当 Character 停止下蹲时调用
CharacterSimple.Subscribe("EndCrouch", function()
-- EndCrouch was called
end)

Jump

当 Character 刚刚开始跳跃时触发的事件
CharacterSimple.Subscribe("Jump", function()
-- Jump was called
end)

Land

在下落过程中着地时调用
CharacterSimple.Subscribe("Land", function()
-- Land was called
end)

MovementModeChange

当角色移动模式发生改变时调用
CharacterSimple.Subscribe("MovementModeChange", function(old_mode, new_mode)
-- MovementModeChange was called
end)

Arguments

TypeArgumentDescription
integerold_mode上一个移动模式
integernew_mode新的移动模式

StartCrouch

当角色开始下蹲时调用
CharacterSimple.Subscribe("StartCrouch", function()
-- StartCrouch was called
end)