跳至正文
版本:bleeding-edge 🩸

基础 Actor

Actor 是一个可以通过 Lua 生成和销毁的对象。
Actor 支持 3D 变换,例如平移(位置)、旋转和缩放。

Actor 是多个实体的基础母版,所有这些实体都共享本页面中所描述的方法事件

👪Base Class
This is a Base Class. Base Classes are abstract definitions used to share common methods and events between related child classes, thus you cannot spawn it directly.

Classes that share methods and events from this Base Class: Billboard, Blueprint, Cable, Character, CharacterSimple, Decal, Gizmo, Grenade, InstancedStaticMesh, Light, Melee, Particle, Prop, SceneCapture, StaticMesh, Sound, TextRender, Text3D, Trigger, VehicleWheeled, VehicleWater, Weapon, Widget3D.
🧑‍💻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!

🗿 静态函数

This class doesn't have own static functions.

🦠 函数

注意

Some of the following methods may not work on certain Actor classes.

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 的距离优化系数
SetForceAdds a permanent force to this Actor, set to Vector(0, 0, 0) to cancel
SetGravityEnabledSets whether gravity is enabled on this Actor
SetHighlightEnabledSets whether the highlight is enabled on this Actor, and which highlight index to use
SetLifeSpanSets the time (in seconds) before this Actor is destroyed. After this time has passed, the actor will be automatically destroyed.
SetLocationSets this Actor's location in the game world
SetNetworkAuthoritySets the Player to have network authority over this Actor
SetNetworkAuthorityAutoDistributedSets if this Actor will auto distribute the network authority between players
SetOutlineEnabledSets whether the outline is enabled on this Actor, and which outline index to use
SetRelativeLocationSets this Actor's relative location in local space (only if this actor is attached)
SetRelativeRotationSets this Actor's relative rotation in local space (only if this actor is attached)
SetRenderCullDistanceSets this Actor's render cull distance
SetRotationSets this Actor's rotation in the game world
SetScaleSets this Actor's scale
SetVisibilitySets whether the actor is visible or not
TranslateToSmoothly moves this actor to a location over a certain time
booleanWasRecentlyRenderedGets if this Actor was recently rendered on screen

AddActorTag

向该 Actor 添加一个虚幻 Actor 标签
my_actor:AddActorTag(tag)

Parameters

TypeParameterDefaultDescription
stringtag Required parameter No description provided

See also RemoveActorTag, GetActorTags.


AddAngularImpulse

向该 Actor 添加角冲量。适用于单次瞬间爆发
my_actor:AddAngularImpulse(angular_impulse, velocity_change?)

Parameters

TypeParameterDefaultDescription
Vectorangular_impulse Required parameter 要施加的冲量大小和方向。方向为旋转轴。单位为弧度
booleanvelocity_change?false是否忽略质量

AddImpulse

向该 Actor 添加冲量。适用于单次瞬间爆发
my_actor:AddImpulse(impulse, velocity_change?)

Parameters

TypeParameterDefaultDescription
Vectorimpulse Required parameter 要施加的冲量大小和方向
booleanvelocity_change?false是否忽略质量

AttachTo

将该 Actor 附加到任何其他 Actor 上,可选择附加在特定骨骼处
local attached_successfully = my_actor:AttachTo(other, attachment_rule?, bone_name?, lifespan_when_detached?, use_absolute_rotation?)

Parameters

TypeParameterDefaultDescription
Base Actorother Required parameter 要附加的其他 Actor
AttachmentRuleattachment_rule?SnapToTarget如何附加
stringbone_name?要附加到哪根骨骼。如果为空,它将附加到 Actor 本身,否则将附加到网格体对应的骨骼/插槽上
floatlifespan_when_detached?-1分离时销毁该 Actor 之前的秒数,设为 0 将在分离时自动销毁该 Actor,设为 10 将在分离 10 秒后销毁
booleanuse_absolute_rotation?false是否强制被附加的对象使用绝对旋转(不会跟随父级移动)

Returns

TypeDescription
boolean是否成功附加

Detach

将该 Actor 从其附加的 Actor 上分离
my_actor:Detach()

GetActorTags

获取该 Actor 上的所有虚幻 Actor 标签
local ret = my_actor:GetActorTags()

Returns

TypeDescription
table of stringNo description provided

See also AddActorTag, RemoveActorTag.


GetAngularForce

获取该 Actor 的角外力(由 SetAngularForce() 设置)
local angular_force = my_actor:GetAngularForce()

Returns

TypeDescription
Vectorangular_force

See also SetAngularForce.


GetAttachedEntities

获取附加到该 Actor 的所有 Actor
local ret = my_actor:GetAttachedEntities()

Returns

TypeDescription
table of Base ActorNo description provided

GetAttachedTo

获取该 Actor 所附加到的父级 Actor
local ret = my_actor:GetAttachedTo()

Returns

TypeDescription
Base Actor or nilNo description provided

GetBounds

获取该 Actor 的边界范围
local ret = my_actor:GetBounds()

Returns

TypeDescription
tablewith this format

GetCollision

获取该 Actor 的碰撞类型
local collision_type = my_actor:GetCollision()

Returns

TypeDescription
CollisionTypecollision_type

See also SetCollision.


GetDimension

获取该 Actor 的维度
local dimension = my_actor:GetDimension()

Returns

TypeDescription
integerdimension

See also SetDimension, DimensionChange.


GetDistanceFromCamera

获取该 Actor 距离相机的距离
local ret = my_actor:GetDistanceFromCamera()

Returns

TypeDescription
floatNo description provided

GetForce

获取该 Actor 的持续外力(由 SetForce() 设置)
local force = my_actor:GetForce()

Returns

TypeDescription
Vectorforce

See also SetForce.


GetLocation

获取该 Actor 在游戏世界中的位置
local location = my_actor:GetLocation()

Returns

TypeDescription
Vectorlocation

See also SetLocation.


GetNetworkAuthority

获取该 Actor 的网络主控玩家
local ret = my_actor:GetNetworkAuthority()

Returns

TypeDescription
Player or nilNo description provided

See also SetNetworkAuthority.


GetRelativeLocation

如果该 Actor 已附加,获取其相对位置
local relative_location = my_actor:GetRelativeLocation()

Returns

TypeDescription
Vectorrelative_location

See also SetRelativeLocation.


GetRelativeRotation

如果该 Actor 已附加,获取其相对旋转
local relative_rotation = my_actor:GetRelativeRotation()

Returns

TypeDescription
Rotatorrelative_rotation

See also SetRelativeRotation.


GetRotation

获取该 Actor 在游戏世界中的角度值
local rotation = my_actor:GetRotation()

Returns

TypeDescription
Rotatorrotation

See also SetRotation.


GetScale

获取该 Actor 的缩放比例
local scale = my_actor:GetScale()

Returns

TypeDescription
Vectorscale

See also SetScale.


GetScreenPercentage

获取该 Actor 在屏幕中所占尺寸的百分比
local ret = my_actor:GetScreenPercentage()

Returns

TypeDescription
floatNo description provided

GetSocketTransform

在给定骨骼或插槽名称的情况下,获取世界空间中的插槽变换
local ret = my_actor:GetSocketTransform(socket_name)

Parameters

TypeParameterDefaultDescription
stringsocket_name Required parameter No description provided

Returns

TypeDescription
tablewith this format

GetVelocity

获取该 Actor 当前的速度
local velocity = my_actor:GetVelocity()

Returns

TypeDescription
Vectorvelocity

HasNetworkAuthority

如果本地玩家当前是该 Actor 的网络主控(Network Authority),则返回 true
local has_network_authority = my_actor:HasNetworkAuthority()

Returns

TypeDescription
booleanhas_network_authority

IsGravityEnabled

如果该 Actor 启用了重力,则返回 true
local gravity_enabled = my_actor:IsGravityEnabled()

Returns

TypeDescription
booleangravity_enabled

See also SetGravityEnabled.


IsInWater

如果该 Actor 处于水中,则返回 true
local in_water = my_actor:IsInWater()

Returns

TypeDescription
booleanin_water

IsNetworkDistributed

如果该 Actor 当前处于网络分配状态,则返回 true。只有处于网络分配状态的 Actor 才能手动设置其网络主控
实体在以下情况时会自动禁用 NetworkDistributed:被附加、被控制、被抓取、被拾取或驾驶中
local ret = my_actor:IsNetworkDistributed()

Returns

TypeDescription
booleanNo description provided

See also SetNetworkAuthorityAutoDistributed, SetNetworkAuthority.


IsVisible

如果该 Actor 可见,则返回 true
local is_visible = my_actor:IsVisible()

Returns

TypeDescription
booleanis_visible

RemoveActorTag

从该 Actor 中移除一个虚幻 Actor 标签
my_actor:RemoveActorTag(tag)

Parameters

TypeParameterDefaultDescription
stringtag Required parameter No description provided

See also AddActorTag, GetActorTags.


RotateTo

在一定时间内平滑旋转该 Actor 到指定角度
my_actor:RotateTo(rotation, time, exp?)

Parameters

TypeParameterDefaultDescription
Rotatorrotation Required parameter No description provided
floattime Required parameter 从当前位置插值到目标位置所需的时间
floatexp?0用于平滑插值的指数。使用 0 表示线性运动

SetAngularForce

向该 Actor 添加一个永久的角外力,设为 Vector(0, 0, 0) 可以取消
my_actor:SetAngularForce(angular_force)

Parameters

TypeParameterDefaultDescription
Vectorangular_force Required parameter No description provided

See also GetAngularForce.


SetCastShadow

设置该 Actor 是否投射阴影
my_actor:SetCastShadow(cast_shadow)

Parameters

TypeParameterDefaultDescription
booleancast_shadow Required parameter No description provided

SetCollision

设置该 Actor 的碰撞类型
my_actor:SetCollision(collision_type)

Parameters

TypeParameterDefaultDescription
CollisionTypecollision_type Required parameter No description provided

See also GetCollision.


SetDimension

设置该 Actor 的维度
my_actor:SetDimension(dimension)

Parameters

TypeParameterDefaultDescription
integerdimension Required parameter No description provided

See also GetDimension, DimensionChange.


SetDistanceOptimizationMultiplier

设置此 Actor 的距离优化系数。
值为 0 时禁用优化。小于 1 的值会减弱优化效果,而大于 1 的值会增强优化效果
my_actor:SetDistanceOptimizationMultiplier(multiplier)

Parameters

TypeParameterDefaultDescription
floatmultiplier Required parameter No description provided

SetForce

Adds a permanent force to this Actor, set to Vector(0, 0, 0) to cancel
my_actor:SetForce(force, is_local?)

Parameters

TypeParameterDefaultDescription
Vectorforce Required parameter No description provided
booleanis_local?trueWhether to apply the force in local space

See also GetForce.


SetGravityEnabled

Sets whether gravity is enabled on this Actor
my_actor:SetGravityEnabled(gravity_enabled)

Parameters

TypeParameterDefaultDescription
booleangravity_enabled Required parameter No description provided

See also IsGravityEnabled.


SetHighlightEnabled

Sets whether the highlight is enabled on this Actor, and which highlight index to use. This will apply the highlight on every attached entity too
my_actor:SetHighlightEnabled(is_enabled, index?)

Parameters

TypeParameterDefaultDescription
booleanis_enabled Required parameter No description provided
integerindex?0Index to use (should be 0, 1 or 2)

See also Client.SetHighlightColor().


SetLifeSpan

Sets the time (in seconds) before this Actor is destroyed. After this time has passed, the actor will be automatically destroyed.
my_actor:SetLifeSpan(seconds)

Parameters

TypeParameterDefaultDescription
floatseconds Required parameter Seconds before being destroyed

SetLocation

Sets this Actor's location in the game world
my_actor:SetLocation(location)

Parameters

TypeParameterDefaultDescription
Vectorlocation Required parameter No description provided

See also GetLocation.


SetNetworkAuthority

Sets the Player to have network authority over this Actor. This Player will be manually assigned to handle this Actor's physics and share its location with other clients. The authority assignment will still be overridden by the game automatically

Please refer to Network Authority for more information
my_actor:SetNetworkAuthority(player?)

Parameters

TypeParameterDefaultDescription
Playerplayer?nilNew player which will assume the Network Authority of this Actor

See also SetNetworkAuthorityAutoDistributed, IsNetworkDistributed, GetNetworkAuthority.


SetNetworkAuthorityAutoDistributed

Sets if this Actor will auto distribute the network authority between players when idle

Please refer to Network Authority for more information
my_actor:SetNetworkAuthorityAutoDistributed(auto_distribute)

Parameters

TypeParameterDefaultDescription
booleanauto_distribute Required parameter If this Actor will be auto network distributed

See also SetNetworkAuthority, IsNetworkDistributed.


SetOutlineEnabled

Sets whether the outline is enabled on this Actor, and which outline index to use. This will apply the outline on every attached entity too
my_actor:SetOutlineEnabled(is_enabled, index?)

Parameters

TypeParameterDefaultDescription
booleanis_enabled Required parameter No description provided
integerindex?0Index to use (should be 0, 1 or 2)

See also Client.SetOutlineColor().


SetRelativeLocation

Sets this Actor's relative location in local space (only if this actor is attached)
my_actor:SetRelativeLocation(relative_location)

Parameters

TypeParameterDefaultDescription
Vectorrelative_location Required parameter No description provided

See also GetRelativeLocation.


SetRelativeRotation

Sets this Actor's relative rotation in local space (only if this actor is attached)
my_actor:SetRelativeRotation(relative_rotation)

Parameters

TypeParameterDefaultDescription
Rotatorrelative_rotation Required parameter No description provided

See also GetRelativeRotation.


SetRenderCullDistance

Sets this Actor's render cull distance. Note: this will only affect the rendering distance, the entity will still be spawned and synced normally regardless of this distance
my_actor:SetRenderCullDistance(max_distance)

Parameters

TypeParameterDefaultDescription
integermax_distance Required parameter No description provided

SetRotation

Sets this Actor's rotation in the game world
my_actor:SetRotation(rotation)

Parameters

TypeParameterDefaultDescription
Rotatorrotation Required parameter No description provided

See also GetRotation.


SetScale

Sets this Actor's scale
my_actor:SetScale(scale)

Parameters

TypeParameterDefaultDescription
Vectorscale Required parameter No description provided

See also GetScale.


SetVisibility

Sets whether the actor is visible or not
my_actor:SetVisibility(is_visible)

Parameters

TypeParameterDefaultDescription
booleanis_visible Required parameter No description provided

TranslateTo

Smoothly moves this actor to a location over a certain time
my_actor:TranslateTo(location, time, exp?)

Parameters

TypeParameterDefaultDescription
Vectorlocation Required parameter No description provided
floattime Required parameter 从当前位置插值到目标位置所需的时间
floatexp?0用于平滑插值的指数。使用 0 表示线性运动

WasRecentlyRendered

Gets if this Actor was recently rendered on screen
local ret = my_actor:WasRecentlyRendered()

Returns

TypeDescription
booleanNo description provided

🚀 事件

NameDescription
DimensionChange当 Actor 改变其维度时触发

DimensionChange

当 Actor 改变其维度时触发
Actor.Subscribe("DimensionChange", function(self, old_dimension, new_dimension)
-- DimensionChange was called
end)

Arguments

TypeArgumentDescription
Base ActorselfNo description provided
integerold_dimensionNo description provided
integernew_dimensionNo description provided

See also SetDimension, GetDimension.