跳至正文
版本:bleeding-edge 🩸

基础可拾取物

可拾取物是特殊的 Actor,可以被角色抓取手持使用

👪Base Class🧑‍💻API Source
👪Base Class
This is a Base Class, an abstract definition that shares common methods and events with it's child classes. You cannot spawn it, and you cannot call anything on the Base Class name itself. Use any class that inherits it.

Classes that share methods and events from this Base Class: Grenade, Melee, Weapon.

它们拥有特殊的方法和事件,当被角色注视时会被高亮显示。

🦠 函数

ReturnsNameDescription
AddSkeletalMeshAttached附加一个骨骼网格体作为该实体的骨骼主姿态
AddStaticMeshAttached附加一个静态网格体到此实体
table of stringGetAllSkeletalMeshAttached获取附加到此实体的所有骨骼网格体
table of stringGetAllStaticMeshAttached获取附加到此实体的所有静态网格体
Character or nilGetHandler获取当前正手持该可拾取物的角色(如果存在)
HandlingModeGetHandlingMode获取该可拾取物的手持模式
SkeletalMesh ReferenceGetMesh获取该可拾取物使用的资产名称
PullUse拉取该可拾取物的使用状态(如果这是武器,将开始开火)
ReleaseUse释放该可拾取物的使用状态(如果这是武器,将停止开火)
RemoveAllSkeletalMeshesAttached移除所有已附加的骨骼网格体
RemoveAllStaticMeshesAttached移除所有已附加的静态网格体
RemoveSkeletalMeshAttached根据自定义 ID 移除此可拾取物上已存在的骨骼网格体(如果存在)
RemoveStaticMeshAttached根据自定义 ID 移除此可拾取物上已存在的静态网格体(如果存在)
SetAttachmentSettings设置此可拾取物的附加设置(即拾取时如何附加到角色上)
SetBuoyancyPontoons设置水体模拟所使用的浮筒
SetBuoyancySettings设置该实体在水中的行为
SetCanUse设置玩家在手持该可拾取物时是否可以使用它
SetCrosshairMaterial设置该可拾取物的准星材质
SetPickable设置玩家是否可以从地面上拾取该可拾取物
SetStaticMeshAttachedTransform设置已附加静态网格体的位置和旋转

Slow

AddSkeletalMeshAttached

生成并附加一个骨骼网格体到此实体,该骨骼网格体必须使用与此 Actor 的网格相同的骨骼,并且将同步其所有动画。使用自定义 ID 以便随后进行移除/自定义设置
🆕Updated Function
This method was recently updated in ver. 1.144. See the Compatibility Versions page for more information.
my_pickable:AddSkeletalMeshAttached(id, skeletal_mesh_path, socket?, relative_location?, relative_rotation?, use_parent_bounds?, use_base_leader_pose_component?, animation_path?, attachable_id?)

Parameters

TypeParameterDefaultDescription
stringid Required parameter 后续用于移除或在其上应用材质设置
SkeletalMesh Referenceskeletal_mesh_path Required parameter 要附加的骨骼网格体资产路径
stringsocket?
要附加到的骨骼插槽
Vectorrelative_location?Vector(0, 0, 0)
相对位置
Rotatorrelative_rotation?Rotator(0, 0, 0)
相对旋转
booleanuse_parent_bounds?true
如果为 true,则该组件在附加时使用其父级的边界。当附加许多组件时,这可以带来显著的优化
booleanuse_base_leader_pose_component?true
如果为 true,此组件将使用基础领头姿态组件来复制其动画
Animation Referenceanimation_path?
要在附加的骨骼网格体上播放的动画资产路径
stringattachable_id?
可选,将此组件附加到另一个已附加的骨骼网格体上(而不是附加到根组件上)

See also RemoveSkeletalMeshAttached.


Slow

AddStaticMeshAttached

在插槽中以相对位置和旋转生成并附加一个静态网格体到此可拾取物。使用自定义 ID 以便随后进行移除/自定义设置
my_pickable:AddStaticMeshAttached(id, static_mesh_path, socket?, relative_location?, relative_rotation?, use_parent_bounds?, attachable_id?)

Parameters

TypeParameterDefaultDescription
stringid Required parameter 分配给该静态网格体的唯一 ID
StaticMesh Referencestatic_mesh_path Required parameter 要附加的静态网格体资产路径
stringsocket?
要附加到的骨骼插槽
Vectorrelative_location?Vector(0, 0, 0)
相对位置
Rotatorrelative_rotation?Rotator(0, 0, 0)
相对旋转
booleanuse_parent_bounds?true
如果为 true,则该组件在附加时使用其父级的边界。当附加许多组件时,这可以带来显著的优化
stringattachable_id?
可选,将此组件附加到另一个已附加的静态网格体上(而不是附加到根组件上)

See also SetStaticMeshAttachedTransform, RemoveStaticMeshAttached.


Optimal

GetAllSkeletalMeshAttached

获取附加到此实体的所有骨骼网格体
local ret = my_pickable:GetAllSkeletalMeshAttached()

Returns

TypeDescription
table of string键为附加 ID,值为资产路径的表

Optimal

GetAllStaticMeshAttached

获取附加到此实体的所有静态网格体
local ret = my_pickable:GetAllStaticMeshAttached()

Returns

TypeDescription
table of string键为附加 ID,值为资产路径的表

Optimal

GetHandler

获取当前正手持该可拾取物的角色(如果存在)
local ret = my_pickable:GetHandler()

Returns

TypeDescription
Character or nilNo description provided

Optimal

GetHandlingMode

获取该可拾取物的手持模式
local ret = my_pickable:GetHandlingMode()

Returns

TypeDescription
HandlingModeNo description provided

Optimal

GetMesh

获取该可拾取物使用的资产名称
local asset = my_pickable:GetMesh()

Returns

TypeDescription
SkeletalMesh Referenceasset

Optimal

PullUse

拉取该可拾取物的使用状态(如果这是武器,将开始开火)
my_pickable:PullUse(release_use_after?)

Parameters

TypeParameterDefaultDescription
floatrelease_use_after?-1
自动释放使用状态的秒数(-1 表示不自动释放,0 表示在一刻后释放)

Optimal

ReleaseUse

释放该可拾取物的使用状态(如果这是武器,将停止开火)
my_pickable:ReleaseUse()

Optimal

RemoveAllSkeletalMeshesAttached

移除所有已附加的骨骼网格体
my_pickable:RemoveAllSkeletalMeshesAttached()

Optimal

RemoveAllStaticMeshesAttached

移除所有已附加的静态网格体
my_pickable:RemoveAllStaticMeshesAttached()

Optimal

RemoveSkeletalMeshAttached

根据自定义 ID 移除此可拾取物上已存在的骨骼网格体(如果存在)
my_pickable:RemoveSkeletalMeshAttached(id)

Parameters

TypeParameterDefaultDescription
stringid Required parameter 要移除的骨骼网格体的唯一 ID

See also AddSkeletalMeshAttached.


Optimal

RemoveStaticMeshAttached

根据自定义 ID 移除此可拾取物上已存在的静态网格体(如果存在)
my_pickable:RemoveStaticMeshAttached(id)

Parameters

TypeParameterDefaultDescription
stringid Required parameter 要移除的静态网格体的唯一 ID

See also AddStaticMeshAttached.


Optimal

SetAttachmentSettings

设置此可拾取物的附加设置(即拾取时如何附加到角色上)
my_pickable:SetAttachmentSettings(relative_location, relative_rotation?, socket?)

Parameters

TypeParameterDefaultDescription
Vectorrelative_location Required parameter 相对于插槽的位置
Rotatorrelative_rotation?Rotator(0, 0, 0)
相对于插槽的旋转
stringsocket?hand_r_socket
被拾取时要附加到的角色插槽

Moderate

SetBuoyancyPontoons

设置用于让该实体浮于水面上的球形浮筒,这将覆盖根据网格体边界和质量自动计算出的浮筒。

不传值(或传入空表)可恢复为自动计算的浮筒。

浮筒仅在启用了水体浮力的地图中生效
my_pickable:SetBuoyancyPontoons(pontoons?)

Parameters

TypeParameterDefaultDescription
tablepontoons?nil
包含浮筒数据的数组,传入 nil 可恢复自动计算的浮筒 with this format

Moderate

SetBuoyancySettings

传入 nil 值将恢复该设置的默认值。

在自动计算浮筒时,修改 buoyancy_coefficient 也会同步重新计算浮筒,因为浮筒半径是由该系数推算出来的。
my_pickable:SetBuoyancySettings(enabled?, buoyancy_coefficient?, buoyancy_damp?, max_buoyant_force?)

Parameters

TypeParameterDefaultDescription
booleanenabled?true
是否施加浮力
floatbuoyancy_coefficient?0.1
漂浮的程度,越高程度越大
floatbuoyancy_damp?1000
垂直速度的一阶阻尼,用于减少起伏
floatmax_buoyant_force?5000000
向上力的最大限制值,防止较轻的物体被直接弹飞出水面

Optimal

SetCanUse

设置玩家在手持该可拾取物时是否可以使用它
my_pickable:SetCanUse(can_use)

Parameters

TypeParameterDefaultDescription
booleancan_use Required parameter No description provided

Optimal

SetCrosshairMaterial

设置该可拾取物的准星材质
my_pickable:SetCrosshairMaterial(material_asset)

Parameters

TypeParameterDefaultDescription
Material Referencematerial_asset Required parameter 准星材质的资产路径

Optimal

SetPickable

设置玩家是否可以从地面上拾取该可拾取物
my_pickable:SetPickable(is_pickable)

Parameters

TypeParameterDefaultDescription
booleanis_pickable Required parameter No description provided

Optimal

SetStaticMeshAttachedTransform

设置已附加静态网格体的位置和旋转
my_pickable:SetStaticMeshAttachedTransform(id, relative_location, relative_rotation)

Parameters

TypeParameterDefaultDescription
stringid Required parameter 通过 AddStaticMeshAttached 设置的静态网格体的唯一 ID
Vectorrelative_location Required parameter 新的相对位置
Rotatorrelative_rotation Required parameter 新的相对旋转

See also AddStaticMeshAttached.

🚀 事件

NameDescription
Drop当角色丢弃该可拾取物时
Hit当该可拾取物撞击到某种物体时触发
Interact当角色与该可拾取物交互时触发(即尝试将其拾取)
PickUp当 Character 拾取该物品时触发
PullUse当角色按下该可拾取物的使用键时触发(即在装备此物品时单击鼠标左键)
ReleaseUse当角色松开该可拾取物的使用键时触发(即在装备此物品时松开鼠标左键)

Drop

当角色丢弃该可拾取物时
<AnyPickableClass>.Subscribe("Drop", function(self, character, was_triggered_by_player)
-- Drop was called
end)

Arguments

TypeArgumentDescription
Base Pickableself被丢弃的可拾取物
Charactercharacter丢弃它的角色
booleanwas_triggered_by_player玩家是否主动按下了丢弃按键来丢弃

Hit

当该可拾取物撞击到某种物体时触发
<AnyPickableClass>.Subscribe("Hit", function(self, impact_force, normal_impulse, impact_location, velocity, other_actor)
-- Hit was called
end)

Arguments

TypeArgumentDescription
Base Pickableself被撞击的 Actor
floatimpact_force撞击力度,已根据可拾取物的重量进行归一化
Vectornormal_impulse撞击的冲量方向
Vectorimpact_location撞击在世界空间中的位置
Vectorvelocity撞击瞬间该可拾取物的速度
Base Actor or nilother_actor与该可拾取物发生撞击的另一个 Actor

Interact

当角色与该可拾取物交互时触发(即尝试将其拾取)

返回 false 以阻止交互
<AnyPickableClass>.Subscribe("Interact", function(self, character)
-- Interact was called
return true
end)

Arguments

TypeArgumentDescription
Base Pickableself刚刚被交互的可拾取物
Charactercharacter与其进行交互的角色

PickUp

当 Character 拾取该物品时触发
<AnyPickableClass>.Subscribe("PickUp", function(self, character)
-- PickUp was called
end)

Arguments

TypeArgumentDescription
Base Pickableself刚刚被拾取的可拾取物
Charactercharacter拾取它的角色

PullUse

当角色按下该可拾取物的使用键时触发(即在装备此物品时单击鼠标左键)
<AnyPickableClass>.Subscribe("PullUse", function(self, character)
-- PullUse was called
end)

Arguments

TypeArgumentDescription
Base Pickableself刚刚被使用的可拾取物
Charactercharacter使用它的角色

ReleaseUse

当角色松开该可拾取物的使用键时触发(即在装备此物品时松开鼠标左键)
<AnyPickableClass>.Subscribe("ReleaseUse", function(self, character)
-- ReleaseUse was called
end)

Arguments

TypeArgumentDescription
Base Pickableself刚刚停止使用的可拾取物
Charactercharacter停止使用它的角色

➕ 可用的准星

nanos world 提供了许多可用于武器/可拾取物的准星材质。 你当然也可以创建并使用自己的准星材质!

所有可用的准星

默认资产包中包含的准星材质列表

  • nanos-world::MI_Crosshair_Circle
  • nanos-world::MI_Crosshair_Crossbow
  • nanos-world::MI_Crosshair_Dot
  • nanos-world::MI_Crosshair_Holo
  • nanos-world::MI_Crosshair_Launcher
  • nanos-world::MI_Crosshair_Regular
  • nanos-world::MI_Crosshair_Regular_X
  • nanos-world::MI_Crosshair_Rocket
  • nanos-world::MI_Crosshair_Separated_Triangle
  • nanos-world::MI_Crosshair_Shotgun
  • nanos-world::MI_Crosshair_Square
  • nanos-world::MI_Crosshair_Submachine
  • nanos-world::MI_Crosshair_Tee
  • nanos-world::MI_Crosshair_ThreeDots
  • nanos-world::MI_Crosshair_Triangle
  • nanos-world::MI_Crosshair_Vee