💣 手榴弹
手榴弹是可拾取物,角色可以抓取并投掷。投掷后 X 秒它会发生爆炸,对周围造成伤害。

💂Authority
This class can only be spawned on 🟦 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
🧑💻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 new_grenade = Grenade(
Vector(-900, 185, 215),
Rotator(0, 90, 90),
"nanos-world::SM_Grenade_G67",
"nanos-world::P_Grenade_Special",
"nanos-world::A_Explosion_Large"
)
🛠 构造函数
Default Constructor
No description provided
local my_grenade = Grenade(location, rotation, static_mesh_asset?, explosion_particles?, explosion_sound?, collision_type?, gravity_enabled?, defer_spawn?)
Parameters
| Type | Name | Default | Description |
|---|---|---|---|
| Vector | location | Required parameter | No description provided |
| Rotator | rotation | Required parameter | No description provided |
| StaticMesh Reference | static_mesh_asset | nanos-world::SM_Grenade_G67 | No description provided |
| Particle Reference | explosion_particles | nanos-world::P_Grenade_Special | No description provided |
| Sound Reference | explosion_sound | nanos-world::A_Explosion_Large | No description provided |
| CollisionType | collision_type | CollisionType.Auto | No description provided |
| boolean | gravity_enabled | true | No description provided |
| boolean | defer_spawn | false | 传入 true 以避免立即将该实体发送给客户端,从而在你想要通过设置多个配置来调整它时提高性能。最后必须调用 FinishSpawn() |
提示
nanos world provides a special Particle* called nanos-world::P_Grenade_Special which spawns different particles depending on the surface it explodes, and also if is underwater.
*This "Particle" is just a special identifier which can only be used on Grenades!
🗿 静态函数
Inherited Entity Static Functions
Grenade inherits from Base Entity Class, sharing it's methods and functions:
Base Entityscripting-reference/classes/base-classes/entity
Base Entityscripting-reference/classes/base-classes/entity
| Returns | Name | Description | |
|---|---|---|---|
| table of Base Entity | GetAll | 返回一个包含调用此方法的类中所有实体的表 | |
| Base Entity | GetByIndex | 返回该类中指定索引处的特定实体 | |
| integer | GetCount | 返回该类当前存在的实体数量 | |
| table of table | GetInheritedClasses | 获取使用 继承系统 创建的、直接继承自该类的所有子类列表 | |
| iterator | GetPairs | 返回一个包含该类所有实体的迭代器,用于 pairs() 循环 | |
| table or nil | GetParentClass | 如果该类是使用 继承系统 创建的,则获取其父类 | |
| table | Inherit | 使用 继承系统 继承此类 | |
| boolean | IsChildOf | 如果该类是使用 继承系统 创建的,检查此类是否为另一个类的子类 | |
| function | Subscribe | 为该类的所有实体订阅一个 事件 | |
| function | SubscribeRemote | 订阅从服务器调用的自定义远程事件 | |
Unsubscribe | 退订此包内该类中此 事件 的所有回调,或者仅取消传入的特定回调 |
This class doesn't have own static functions.
🦠 函数
Inherited Entity Functions
Grenade inherits from Base Entity Class, sharing it's methods and functions:
Base Entityscripting-reference/classes/base-classes/entity
Base Entityscripting-reference/classes/base-classes/entity
| Returns | Name | Description | |
|---|---|---|---|
BroadcastRemoteEvent | 直接在此实体上向所有玩家调用自定义远程事件 | ||
BroadcastRemoteInRadiusEvent | 直接针对此实体调用自定义远程事件,并将该事件传递给半径范围内的所有玩家 | ||
CallRemoteEvent | 直接在此实体上向特定玩家调用自定义远程事件 | ||
CallRemoteEvent | 直接在此实体上调用自定义远程事件 | ||
CallRemotePlayersEvent | 直接在此实体上调用自定义远程事件,并将事件传递给玩家列表 | ||
Destroy | 销毁该实体 | ||
FinishSpawn | 完成生成过程,如果实体是通过 defer_spawn 生成的,则将实体发送给客户端 | ||
| table of string | GetAllValuesKeys | 获取所有值键的列表 | |
| table | GetClass | 获取该实体的类 | |
| integer | GetID | 获取该实体的全网通用网络 ID(在客户端和服务器上相同) | |
| any | GetValue | 获取此实体上存储在给定键处的 值 | |
| boolean | HasAuthority | 获取本地上下文是否对此实体拥有主控(如果由客户端生成则为 true,由服务器生成则为 false) | |
| boolean | IsA | 递归检查此实体是否继承自某个类 | |
| boolean | IsBeingDestroyed | 如果该实体正在被销毁,则返回 true | |
| boolean | IsValid | 如果该实体有效(即未被销毁且指向一个有效的实体),则返回 true | |
SetValue | 在此实体中设置一个值 | ||
| function | Subscribe | 在这个特定实体上订阅一个事件 | |
| function | SubscribeRemote | 在这个特定实体上订阅一个从服务器调用的自定义远程事件 | |
Unsubscribe | 退订此包内该实体中此 事件 的所有回调,或者仅取消传入的特定回调 |
Inherited Actor Functions
Grenade inherits from Base Actor Class, sharing it's methods and functions:
Base Actorscripting-reference/classes/base-classes/actor
Base Actorscripting-reference/classes/base-classes/actor
| Returns | Name | Description | |
|---|---|---|---|
AddActorTag | 向该 Actor 添加一个虚幻 Actor 标签 | ||
AddAngularImpulse | 向该 Actor 添加角冲量。适用于单次瞬间爆发 | ||
AddImpulse | 向该 Actor 添加冲量。适用于单次瞬间爆发 | ||
| boolean | AttachTo | 将该 Actor 附加到任何其他 Actor 上,可选择附加在特定骨骼处 | |
Detach | 将该 Actor 从其附加的 Actor 上分离 | ||
| table of string | GetActorTags | 获取该 Actor 上的所有虚幻 Actor 标签 | |
| Vector | GetAngularForce | 获取该 Actor 的角外力(由 SetAngularForce() 设置) | |
| float | GetAngularVelocity | Returns the angular velocity of this Actor | |
| table of Base Actor | GetAttachedEntities | 获取附加到该 Actor 的所有 Actor | |
| Base Actor or nil | GetAttachedTo | 获取该 Actor 所附加到的父级 Actor | |
| table | GetBounds | 获取该 Actor 的边界范围 | |
| CollisionType | GetCollision | 获取该 Actor 的碰撞类型 | |
| integer | GetDimension | 获取该 Actor 的维度 | |
| float | GetDistanceFromCamera | 获取该 Actor 距离相机的距离 | |
| Vector | GetForce | 获取该 Actor 的持续外力(由 SetForce() 设置) | |
| Vector | GetLocation | 获取该 Actor 在游戏世界中的位置 | |
| float | GetMass | Returns the mass of this Actor | |
| Player or nil | GetNetworkAuthority | 获取该 Actor 的网络主控玩家 | |
| Vector | GetRelativeLocation | 如果该 Actor 已附加,获取其相对位置 | |
| Rotator | GetRelativeRotation | 如果该 Actor 已附加,获取其相对旋转 | |
| Rotator | GetRotation | 获取该 Actor 在游戏世界中的角度值 | |
| Vector | GetScale | 获取该 Actor 的缩放比例 | |
| float | GetScreenPercentage | 获取该 Actor 在屏幕中所占尺寸的百分比 | |
| table | GetSocketTransform | 在给定骨骼或插槽名称的情况下,获取世界空间中的插槽变换 | |
| Vector | GetVelocity | 获取该 Actor 当前的速度 | |
| boolean | HasNetworkAuthority | 如果本地玩家当前是该 Actor 的网络主控(Network Authority),则返回 true | |
| boolean | IsGravityEnabled | 如果该 Actor 启用了重力,则返回 true | |
| boolean | IsInWater | 如果该 Actor 处于水中,则返回 true | |
| boolean | IsNetworkDistributed | 如果该 Actor 当前处于网络分配状态,则返回 true | |
| boolean | IsVisible | 如果该 Actor 可见,则返回 true | |
RemoveActorTag | 从该 Actor 中移除一个虚幻 Actor 标签 | ||
RotateTo | 在一定时间内平滑旋转该 Actor 到指定角度 | ||
SetAngularForce | 向该 Actor 添加一个永久的角外力,设为 Vector(0, 0, 0) 可以取消 | ||
SetCastShadow | 设置该 Actor 是否投射阴影 | ||
SetCollision | 设置该 Actor 的碰撞类型 | ||
SetDimension | 设置该 Actor 的维度 | ||
SetDistanceOptimizationMultiplier | Sets this Actor's distance optimization multiplier | ||
SetForce | Adds a permanent force to this Actor, set to Vector(0, 0, 0) to cancel | ||
SetGravityEnabled | Sets whether gravity is enabled on this Actor | ||
SetHighlightEnabled | Sets whether the highlight is enabled on this Actor, and which highlight index to use | ||
SetLifeSpan | Sets the time (in seconds) before this Actor is destroyed. After this time has passed, the actor will be automatically destroyed. | ||
SetLocation | Sets this Actor's location in the game world | ||
SetNetworkAuthority | Sets the Player to have network authority over this Actor | ||
SetNetworkAuthorityAutoDistributed | Sets if this Actor will auto distribute the network authority between players | ||
SetOutlineEnabled | Sets whether the outline is enabled on this Actor, and which outline index to use | ||
SetRelativeLocation | Sets this Actor's relative location in local space (only if this actor is attached) | ||
SetRelativeRotation | Sets this Actor's relative rotation in local space (only if this actor is attached) | ||
SetRenderCullDistance | Sets this Actor's render cull distance | ||
SetRotation | Sets this Actor's rotation in the game world | ||
SetScale | Sets this Actor's scale | ||
SetVisibility | Sets whether the actor is visible or not | ||
TranslateTo | Smoothly moves this actor to a location over a certain time | ||
| boolean | WasRecentlyRendered | Gets if this Actor was recently rendered on screen |
Inherited Paintable Functions
Grenade inherits from Base Paintable Class, sharing it's methods and functions:
Base Paintablescripting-reference/classes/base-classes/paintable
Base Paintablescripting-reference/classes/base-classes/paintable
| Returns | Name | Description | |
|---|---|---|---|
| Color | GetMaterialColorParameter | 从该 Actor 的材质中获取 Color 参数 | |
| float | GetMaterialScalarParameter | 从该 Actor 的材质中获取 Scalar 参数 | |
| string | GetMaterialTextureParameter | 从该 Actor 的材质中获取 Texture 参数 | |
| Vector | GetMaterialVectorParameter | 从该 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 Pickable Functions
Grenade inherits from Base Pickable Class, sharing it's methods and functions:
Base Pickablescripting-reference/classes/base-classes/pickable
Base Pickablescripting-reference/classes/base-classes/pickable
| Returns | Name | Description | |
|---|---|---|---|
AddSkeletalMeshAttached | 附加一个骨骼网格体作为该实体的骨骼主姿态 | ||
AddStaticMeshAttached | 附加一个静态网格体到此实体 | ||
| table of string | GetAllSkeletalMeshAttached | 获取附加到此实体的所有骨骼网格体 | |
| table of string | GetAllStaticMeshAttached | 获取附加到此实体的所有静态网格体 | |
| Character or nil | GetHandler | 获取当前正手持该可拾取物的角色(如果存在) | |
| HandlingMode | GetHandlingMode | 获取该可拾取物的手持模式 | |
| SkeletalMesh Reference | GetMesh | 获取该可拾取物使用的资产名称 | |
PullUse | 拉取该可拾取物的使用状态(如果这是武器,将开始开火) | ||
ReleaseUse | 释放该可拾取物的使用状态(如果这是武器,将停止开火) | ||
RemoveAllSkeletalMeshesAttached | 移除所有已附加的骨骼网格体 | ||
RemoveAllStaticMeshesAttached | 移除所有已附加的静态网格体 | ||
RemoveSkeletalMeshAttached | 根据自定义 ID 移除此可拾取物上已存在的骨骼网格体(如果存在) | ||
RemoveStaticMeshAttached | 根据自定义 ID 移除此可拾取物上已存在的静态网格体(如果存在) | ||
SetAttachmentSettings | 设置此可拾取物的附加设置(即拾取时如何附加到角色上) | ||
SetCanUse | 设置玩家在手持该可拾取物时是否可以使用它 | ||
SetCrosshairMaterial | 设置该可拾取物的准星材质 | ||
SetPickable | 设置玩家是否可以从地面上拾取该可拾取物 | ||
SetStaticMeshAttachedTransform | 设置已附加静态网格体的位置和旋转 |
| Returns | Name | Description | |
|---|---|---|---|
Explode | 强制此手榴弹爆炸 | ||
| float | GetBaseDamage | 内半径处的伤害 | |
| float | GetDamageFalloff | 等比例应用 BaseDamage 的半径衰减 | |
| float | GetDamageInnerRadius | 应用 BaseDamage 的半径范围 | |
| float | GetDamageOuterRadius | 应用 MinimumDamage 的半径范围 | |
| float | GetMinimumDamage | 外半径处的伤害 | |
| float | GetThrowForce | 投掷时施加的冲量 | |
| float | GetTimeToExplode | 距离爆炸的时间 | |
SetDamage | 设置此手榴弹的伤害参数 | ||
SetThrowForce | 设置投掷时施加的冲量 | ||
SetTimeToExplode | 设置投掷后距离爆炸的时间 |


Explode
强制此手榴弹爆炸
my_grenade:Explode()
See also Explode.


GetBaseDamage
内半径处的伤害
local base_damage = my_grenade:GetBaseDamage()
Returns
| Type | Description |
|---|---|
| float | base_damage |
See also SetDamage.


GetDamageFalloff
等比例应用 BaseDamage 的半径衰减
local damage_falloff = my_grenade:GetDamageFalloff()
Returns
| Type | Description |
|---|---|
| float | damage_falloff |
See also SetDamage.


GetDamageInnerRadius
应用 BaseDamage 的半径范围
local damage_inner_radius = my_grenade:GetDamageInnerRadius()
Returns
| Type | Description |
|---|---|
| float | damage_inner_radius |
See also SetDamage.


GetDamageOuterRadius
应用 MinimumDamage 的半径范围
local damage_outer_radius = my_grenade:GetDamageOuterRadius()
Returns
| Type | Description |
|---|---|
| float | damage_outer_radius |
See also SetDamage.


GetMinimumDamage
外半径处的伤害
local minimum_damage = my_grenade:GetMinimumDamage()
Returns
| Type | Description |
|---|---|
| float | minimum_damage |
See also SetDamage.


GetThrowForce
投掷时施加的冲量
local throw_force = my_grenade:GetThrowForce()
Returns
| Type | Description |
|---|---|
| float | throw_force |
See also SetThrowForce.


GetTimeToExplode
距离爆炸的时间
local time = my_grenade:GetTimeToExplode()
Returns
| Type | Description |
|---|---|
| float | time |
See also SetTimeToExplode.


SetDamage
设置此手榴弹的伤害参数
my_grenade:SetDamage(base_damage?, minimum_damage?, damage_inner_radius?, damage_outer_radius?, damage_falloff?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | base_damage? | 90 | 内半径范围内的最大伤害 |
| integer | minimum_damage? | 0 | 外半径边缘的最小伤害 |
| integer | damage_inner_radius? | 200 | 伤害为 100% 的半径范围 |
| integer | damage_outer_radius? | 1000 | 通过衰减插值计算伤害的半径范围 |
| float | damage_falloff? | 1 | 最大伤害与最小伤害之间的线性插值函数 |
See also GetBaseDamage, GetDamageFalloff, GetDamageInnerRadius, GetDamageOuterRadius, GetMinimumDamage.


SetThrowForce
设置投掷时施加的冲量
my_grenade:SetThrowForce(throw_force)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | throw_force | Required parameter | No description provided |
See also GetThrowForce.


SetTimeToExplode
设置投掷后距离爆炸的时间
my_grenade:SetTimeToExplode(time)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| float | time | Required parameter | 时间(秒) |
See also GetTimeToExplode.
🚀 事件
Inherited Entity Events
Grenade inherits from Base Entity Class, sharing it's events:
Base Entityscripting-reference/classes/base-classes/entity
Base Entityscripting-reference/classes/base-classes/entity
| Name | Description | |
|---|---|---|
ClassRegister | 当使用 继承系统 注册一个新类时触发 | |
Destroy | 当实体被销毁时触发 | |
Spawn | 当实体被生成/创建时触发 | |
ValueChange | 当实体通过 :SetValue() 改变了值时触发 |
Inherited Actor Events
Grenade inherits from Base Actor Class, sharing it's events:
Base Actorscripting-reference/classes/base-classes/actor
Base Actorscripting-reference/classes/base-classes/actor
| Name | Description | |
|---|---|---|
DimensionChange | 当 Actor 改变其维度时触发 | |
NetworkAuthorityChange | Triggered when an Actor changes its network authority Player | |
NetworkAuthorityChange | Triggered when the local Player gets/loses network authority over this actor |
Inherited Pickable Events
Grenade inherits from Base Pickable Class, sharing it's events:
Base Pickablescripting-reference/classes/base-classes/pickable
Base Pickablescripting-reference/classes/base-classes/pickable

Explode
当手榴弹爆炸时触发
Grenade.Subscribe("Explode", function(self)
-- Explode was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| Grenade | self | 爆炸的手榴弹 |
See also Explode.

Throw
当手榴弹被投掷时触发
Grenade.Subscribe("Throw", function(self, handler)
-- Throw was called
end)