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.

AddActorTag
向该 Actor 添加一个虚幻 Actor 标签
my_actor:AddActorTag(tag)
Parameters
| Type | Parameter | Default | Description |
|---|
| string | tag | Required parameter | No description provided |
See also RemoveActorTag, GetActorTags.

AddAngularImpulse
向该 Actor 添加角冲量。适用于单次瞬间爆发
my_actor:AddAngularImpulse(angular_impulse, velocity_change?)
Parameters
| Type | Parameter | Default | Description |
|---|
| Vector | angular_impulse | Required parameter | 要施加的冲量大小和方向。方向为旋转轴。单位为弧度 |
| boolean | velocity_change? | false | 是否忽略质量 |

AddImpulse
向该 Actor 添加冲量。适用于单次瞬间爆发
my_actor:AddImpulse(impulse, velocity_change?)
Parameters
| Type | Parameter | Default | Description |
|---|
| Vector | impulse | Required parameter | 要施加的冲量大小和方向 |
| boolean | velocity_change? | false | 是否忽略质量 |

AttachTo
将该 Actor 附加到任何其他 Actor 上,可选择附加在特定骨骼处
local attached_successfully = my_actor:AttachTo(other, attachment_rule?, bone_name?, lifespan_when_detached?, use_absolute_rotation?)
Parameters
| Type | Parameter | Default | Description |
|---|
| Base Actor | other | Required parameter | 要附加的其他 Actor |
| AttachmentRule | attachment_rule? | SnapToTarget | 如何附加 |
| string | bone_name? | | 要附加到哪根骨骼。如果为空,它将附加到 Actor 本身,否则将附加到网格体对应的骨骼/插槽上 |
| float | lifespan_when_detached? | -1 | 分离时销毁该 Actor 之前的秒数,设为 0 将在分离时自动销毁该 Actor,设为 10 将在分离 10 秒后销毁 |
| boolean | use_absolute_rotation? | false | 是否强制被附加的对象使用绝对旋转(不会跟随父级移动) |

Detach
将该 Actor 从其附加的 Actor 上分离
获取该 Actor 上的所有虚幻 Actor 标签
local ret = my_actor:GetActorTags()
See also AddActorTag, RemoveActorTag.

GetAngularForce
获取该 Actor 的角外力(由 SetAngularForce() 设置)
local angular_force = my_actor:GetAngularForce()
Returns
| Type | Description |
|---|
| Vector | angular_force |
See also SetAngularForce.

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

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

GetBounds
获取该 Actor 的边界范围
local ret = my_actor:GetBounds()
Returns
| Type | Description |
|---|
| table | with this format |

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

GetDimension
获取该 Actor 的维度
local dimension = my_actor:GetDimension()
See also SetDimension, DimensionChange.

GetDistanceFromCamera
获取该 Actor 距离相机的距离
local ret = my_actor:GetDistanceFromCamera()
Returns
| Type | Description |
|---|
| float | No description provided |

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

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

GetNetworkAuthority
获取该 Actor 的网络主控玩家
local ret = my_actor:GetNetworkAuthority()
Returns
| Type | Description |
|---|
| Player or nil | No description provided |
See also SetNetworkAuthority.

GetRelativeLocation
如果该 Actor 已附加,获取其相对位置
local relative_location = my_actor:GetRelativeLocation()
Returns
| Type | Description |
|---|
| Vector | relative_location |
See also SetRelativeLocation.

GetRelativeRotation
如果该 Actor 已附加,获取其相对旋转
local relative_rotation = my_actor:GetRelativeRotation()
Returns
| Type | Description |
|---|
| Rotator | relative_rotation |
See also SetRelativeRotation.

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

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

GetScreenPercentage
获取该 Actor 在屏幕中所占尺寸的百分比
local ret = my_actor:GetScreenPercentage()
Returns
| Type | Description |
|---|
| float | No description provided |
在给定骨骼或插槽名称的情况下,获取世界空间中的插槽变换
local ret = my_actor:GetSocketTransform(socket_name)
Parameters
| Type | Parameter | Default | Description |
|---|
| string | socket_name | Required parameter | No description provided |
Returns
| Type | Description |
|---|
| table | with this format |

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

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

IsGravityEnabled
如果该 Actor 启用了重力,则返回 true
local gravity_enabled = my_actor:IsGravityEnabled()
Returns
| Type | Description |
|---|
| boolean | gravity_enabled |
See also SetGravityEnabled.

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

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

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

RemoveActorTag
从该 Actor 中移除一个虚幻 Actor 标签
my_actor:RemoveActorTag(tag)
Parameters
| Type | Parameter | Default | Description |
|---|
| string | tag | Required parameter | No description provided |
See also AddActorTag, GetActorTags.

RotateTo
在一定时间内平滑旋转该 Actor 到指定角度
my_actor:RotateTo(rotation, time, exp?)
Parameters
| Type | Parameter | Default | Description |
|---|
| Rotator | rotation | Required parameter | No description provided |
| float | time | Required parameter | 从当前位置插值到目标位置所需的时间 |
| float | exp? | 0 | 用于平滑插值的指数。使用 0 表示线性运动 |

SetAngularForce
向该 Actor 添加一个永久的角外力,设为 Vector(0, 0, 0) 可以取消
my_actor:SetAngularForce(angular_force)
Parameters
| Type | Parameter | Default | Description |
|---|
| Vector | angular_force | Required parameter | No description provided |
See also GetAngularForce.

SetCastShadow
设置该 Actor 是否投射阴影
my_actor:SetCastShadow(cast_shadow)
Parameters
| Type | Parameter | Default | Description |
|---|
| boolean | cast_shadow | Required parameter | No description provided |

SetCollision
设置该 Actor 的碰撞类型
my_actor:SetCollision(collision_type)
Parameters
| Type | Parameter | Default | Description |
|---|
| CollisionType | collision_type | Required parameter | No description provided |
See also GetCollision.

SetDimension
设置该 Actor 的维度
my_actor:SetDimension(dimension)
Parameters
| Type | Parameter | Default | Description |
|---|
| integer | dimension | Required parameter | No description provided |
See also GetDimension, DimensionChange.

SetDistanceOptimizationMultiplier
设置此 Actor 的距离优化系数。
值为 0 时禁用优化。小于 1 的值会减弱优化效果,而大于 1 的值会增强优化效果
my_actor:SetDistanceOptimizationMultiplier(multiplier)
Parameters
| Type | Parameter | Default | Description |
|---|
| float | multiplier | 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
| Type | Parameter | Default | Description |
|---|
| Vector | force | Required parameter | No description provided |
| boolean | is_local? | true | Whether 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
| Type | Parameter | Default | Description |
|---|
| boolean | gravity_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
| Type | Parameter | Default | Description |
|---|
| boolean | is_enabled | Required parameter | No description provided |
| integer | index? | 0 | Index 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
| Type | Parameter | Default | Description |
|---|
| float | seconds | Required parameter | Seconds before being destroyed |

SetLocation
Sets this Actor's location in the game world
my_actor:SetLocation(location)
Parameters
| Type | Parameter | Default | Description |
|---|
| Vector | location | 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
| Type | Parameter | Default | Description |
|---|
| Player | player? | nil | New 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
| Type | Parameter | Default | Description |
|---|
| boolean | auto_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
| Type | Parameter | Default | Description |
|---|
| boolean | is_enabled | Required parameter | No description provided |
| integer | index? | 0 | Index 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
| Type | Parameter | Default | Description |
|---|
| Vector | relative_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
| Type | Parameter | Default | Description |
|---|
| Rotator | relative_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
| Type | Parameter | Default | Description |
|---|
| integer | max_distance | Required parameter | No description provided |

SetRotation
Sets this Actor's rotation in the game world
my_actor:SetRotation(rotation)
Parameters
| Type | Parameter | Default | Description |
|---|
| Rotator | rotation | Required parameter | No description provided |
See also GetRotation.

SetScale
Sets this Actor's scale
Parameters
| Type | Parameter | Default | Description |
|---|
| Vector | scale | Required parameter | No description provided |
See also GetScale.

SetVisibility
Sets whether the actor is visible or not
my_actor:SetVisibility(is_visible)
Parameters
| Type | Parameter | Default | Description |
|---|
| boolean | is_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
| Type | Parameter | Default | Description |
|---|
| Vector | location | Required parameter | No description provided |
| float | time | Required parameter | 从当前位置插值到目标位置所需的时间 |
| float | exp? | 0 | 用于平滑插值的指数。使用 0 表示线性运动 |

WasRecentlyRendered
Gets if this Actor was recently rendered on screen
local ret = my_actor:WasRecentlyRendered()
Returns
| Type | Description |
|---|
| boolean | No description provided |
🚀 事件

DimensionChange
当 Actor 改变其维度时触发
Actor.Subscribe("DimensionChange", function(self, old_dimension, new_dimension)
end)
Arguments
| Type | Argument | Description |
|---|
| Base Actor | self | No description provided |
| integer | old_dimension | No description provided |
| integer | new_dimension | No description provided |
See also SetDimension, GetDimension.