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

基础可拾取物

可拾取物是特殊的 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: Grenade, Melee, Weapon.
🧑‍💻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!

They have special methods and events and are highlighted when looked at by a Character.

🦠 函数

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

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
If true, this component uses its parents bounds when attached. This can be a significant optimization with many components attached together
booleanuse_base_leader_pose_component?true
如果为 true,此组件将使用基础领头姿态组件来复制其动画
Animation Referenceanimation_path?
要在附加的骨骼网格体上播放的动画资产路径
stringattachable_id?
Optionally attaches this to another attached skeletal mesh (instead of attaching to the root component)

See also RemoveSkeletalMeshAttached.


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
If true, this component uses its parents bounds when attached. This can be a significant optimization with many components attached together
stringattachable_id?
可选,将此组件附加到另一个已附加的静态网格体上(而不是附加到根组件上)

See also SetStaticMeshAttachedTransform, RemoveStaticMeshAttached.


GetAllSkeletalMeshAttached

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

Returns

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

GetAllStaticMeshAttached

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

Returns

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

GetHandler

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

Returns

TypeDescription
Character or nilNo description provided

GetHandlingMode

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

Returns

TypeDescription
HandlingModeNo description provided

GetMesh

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

Returns

TypeDescription
SkeletalMesh Referenceasset

PullUse

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

Parameters

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

ReleaseUse

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

RemoveAllSkeletalMeshesAttached

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

RemoveAllStaticMeshesAttached

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

RemoveSkeletalMeshAttached

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

Parameters

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

See also AddSkeletalMeshAttached.


RemoveStaticMeshAttached

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

Parameters

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

See also AddStaticMeshAttached.


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
被拾取时要附加到的角色插槽

SetCanUse

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

Parameters

TypeParameterDefaultDescription
booleancan_use Required parameter No description provided

SetCrosshairMaterial

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

Parameters

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

SetPickable

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

Parameters

TypeParameterDefaultDescription
booleanis_pickable Required parameter No description provided

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

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

Arguments

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

Hit

当该可拾取物撞击到某种物体时触发
Pickable.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 以阻止交互
Pickable.Subscribe("Interact", function(self, character)
-- Interact was called
return true
end)

Arguments

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

PickUp

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

Arguments

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

PullUse

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

Arguments

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

ReleaseUse

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

Arguments

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

➕ Available Crosshairs

nanos world provides a bunch of crosshair materials which can be used in Weapons/Pickables. You can of course create your own crosshair material and use those instead!

All available Crosshairs

List of crosshair materials included in the default asset pack

  • 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