跳至正文
版本:latest - a1.147.x ⚖️

📦 道具

道具代表一个可以在世界中生成的动态网格体,它拥有物理效果,并可以被角色抓取并移动。


💂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.
🧑‍💻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!

🎒 示例

local my_prop = Prop(
Vector(-900, 185, 215),
Rotator(0, 90, 90),
"nanos-world::SM_Crate_07"
)

🛠 构造函数

Default Constructor

No description provided

local my_prop = Prop(location, rotation, asset, collision_type?, gravity_enabled?, grab_mode?, ccd_mode?, defer_spawn?)

Parameters

TypeNameDefaultDescription
Vectorlocation Required parameter No description provided
Rotatorrotation Required parameter No description provided
StaticMesh Referenceasset Required parameter No description provided
CollisionTypecollision_typeCollisionType.Auto设为 CollisionType.Auto 时,如果道具的半径小于 40 个单位,它将在 NormalIgnoreOnlyPawn 之间自动切换。
booleangravity_enabledtrueNo description provided
GrabModegrab_modeGrabMode.Auto该道具是否可以被抓取
CCDModeccd_modeCCDMode.Auto该道具是否应当启用 CCD(如果道具较小,禁用此项可能会导致其穿透物体)。在“仅限视觉效果”的道具上强制禁用它是明智的选择。
booleandefer_spawnfalse传入 true 以避免立即将该实体发送给客户端,从而在你想要通过设置多个配置来调整它时提高性能。最后必须调用 FinishSpawn()
信息

If the Prop was spawned by the Client. It will have all interactions disabled (e.g. it will not be able to be grabbed by Characters).

信息

Props smaller than radius 40 units or very thin (any side smaller than 20 units) will have CCD (Continuous Collision Detection) enabled automatically to avoid falling through the floor or other objects. This will slightly increase the performance cost of them!

🗿 静态函数

Inherited Entity Static Functions
Prop 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
Prop 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获取此实体上存储在给定键处的
booleanHasAuthority获取本地上下文是否对此实体拥有主控(如果由客户端生成则为 true,由服务器生成则为 false)
booleanIsA递归检查此实体是否继承自某个类
booleanIsBeingDestroyed如果该实体正在被销毁,则返回 true
booleanIsValid如果该实体有效(即未被销毁且指向一个有效的实体),则返回 true
SetValue在此实体中设置一个
functionSubscribe在这个特定实体上订阅一个事件
functionSubscribeRemote在这个特定实体上订阅一个从服务器调用的自定义远程事件
Unsubscribe退订此包内该实体中此 事件 的所有回调,或者仅取消传入的特定回调
Inherited Actor Functions
Prop 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 的距离优化系数
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
Inherited Paintable Functions
Prop 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 的物理材质
ReturnsNameDescription
GrabModeGetGrabMode获取抓取该道具的能力
Character or nilGetHandler获取当前正手持该物体的角色(如果存在)
floatGetMassOverride获取覆盖的质量
floatGetMassScale获取质量缩放值
StaticMesh ReferenceGetMesh获取资产名称
SetGrabMode设置角色抓取该道具的能力
SetInteractionToolTipText设置角色与该道具交互时显示的交互提示文本
SetMassOverride覆盖该道具的质量(千克)
SetMassScale更改用于计算该道具质量的质量缩放值
SetMesh在运行时更改网格体
SetPhysicsDamping设置该道具的物理阻尼

GetGrabMode

获取抓取该道具的能力
local grab_mode = my_prop:GetGrabMode()

Returns

TypeDescription
GrabModegrab_mode

See also SetGrabMode.


GetHandler

获取当前正手持该物体的角色(如果存在)
local handler = my_prop:GetHandler()

Returns

TypeDescription
Character or nil手持该物体的角色

GetMassOverride

获取覆盖的质量
local ret = my_prop:GetMassOverride()

Returns

TypeDescription
float覆盖的质量

See also SetMassOverride.


GetMassScale

获取质量缩放值
local ret = my_prop:GetMassScale()

Returns

TypeDescription
float质量缩放值

See also SetMassScale.


GetMesh

获取资产名称
local asset = my_prop:GetMesh()

Returns

TypeDescription
StaticMesh Reference资产名称

See also SetMesh.


SetGrabMode

设置角色抓取该道具的能力
my_prop:SetGrabMode(grab_mode)

Parameters

TypeParameterDefaultDescription
GrabModegrab_mode Required parameter 该道具是否可以被抓取。设为 Auto 将根据道具的大小自动决定。

See also GetGrabMode.


SetInteractionToolTipText

设置角色与该道具交互时显示的交互提示文本
my_prop:SetInteractionToolTipText(tool_tip_text)

Parameters

TypeParameterDefaultDescription
stringtool_tip_text Required parameter 要在交互提示中显示的文本

SetMassOverride

覆盖该道具的质量(千克)
my_prop:SetMassOverride(mass)

Parameters

TypeParameterDefaultDescription
floatmass Required parameter 要覆盖的质量(千克)。传入 -1 可重置为默认值

See also GetMassOverride.


SetMassScale

更改用于计算该道具质量的质量缩放值
my_prop:SetMassScale(scale)

Parameters

TypeParameterDefaultDescription
floatscale Required parameter No description provided

See also GetMassScale.


SetMesh

在运行时更改网格体
my_prop:SetMesh(asset)

Parameters

TypeParameterDefaultDescription
StaticMesh Referenceasset Required parameter 资产

See also GetMesh.


SetPhysicsDamping

设置该道具的物理阻尼
my_prop:SetPhysicsDamping(linear_damping, angular_damping)

Parameters

TypeParameterDefaultDescription
floatlinear_damping Required parameter 线速度阻尼值
floatangular_damping Required parameter 角速度阻尼值

🚀 事件

Inherited Entity Events
Prop 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
Prop inherits from Base Actor Class, sharing it's events:
Base Actorscripting-reference/classes/base-classes/actor
NameDescription
DimensionChange当 Actor 改变其维度时触发
NameDescription
Grab当角色抓取道具时触发
Hit当该道具撞击到某种物体时触发
Interact当角色与该道具交互时触发(即尝试抓取它)
TakeDamage当道具受到伤害时触发
UnGrab当该道具被取消抓取时触发

Grab

当角色抓取道具时触发
Prop.Subscribe("Grab", function(self, character)
-- Grab was called
end)

Arguments

TypeArgumentDescription
Propself被抓取的道具
Charactercharacter新的抓取者

Hit

当该道具撞击到某种物体时触发
Prop.Subscribe("Hit", function(self, impact_force, normal_impulse, impact_location, velocity, other_actor)
-- Hit was called
end)

Arguments

TypeArgumentDescription
Propself被撞击的道具
floatimpact_force撞击力度,已根据道具的重量进行归一化处理
Vectornormal_impulse撞击的冲量方向
Vectorimpact_location撞击在世界 3D 空间中的位置
Vectorvelocity撞击瞬间该道具的速度
Base Actor or nilother_actor与该道具发生撞击的另一个 Actor

Interact

当角色与该道具交互时触发(即尝试抓取它)

返回 false 以阻止该交互(例如防止被抓取)
Prop.Subscribe("Interact", function(self, character)
-- Interact was called
return true
end)

Arguments

TypeArgumentDescription
Propself承受交互的对象
Charactercharacter与该对象进行交互的角色

TakeDamage

当道具受到伤害时触发
Prop.Subscribe("TakeDamage", function(self, damage, bone, type, from_direction, instigator, causer)
-- TakeDamage was called
end)

Arguments

TypeArgumentDescription
Propself受到伤害的对象
integerdamage伤害量
stringbone受损的骨骼
DamageTypetype伤害类型
Vectorfrom_direction伤害相对于受伤 Actor 的方向
Player or nilinstigator造成伤害的玩家
Base Actor or nilcauser造成伤害的对象

UnGrab

当该道具被取消抓取时触发
Prop.Subscribe("UnGrab", function(self, character)
-- UnGrab was called
end)

Arguments

TypeArgumentDescription
Propself被取消抓取的道具
Charactercharacter原先的抓取者