EquipAttachment

Method

Equip an attachment to the avatar (Defined by the SpatialAvatarAttachment component)

Definition

EquipAttachmentRequest EquipAttachment(AssetType assetType, string assetID, bool equip = true, bool clearOccupiedPrimarySlot = true, string optionalTag = null)
EquipAttachmentRequest EquipAttachment(AssetType assetType, string assetID, bool equip = true, bool clearOccupiedPrimarySlot = true, string optionalTag = null)

Returns EquipAttachmentRequest

Parameters

ParameterDescription
AssetType assetType

Which asset type to play this from. For BackpackItem, this will only work if the user owns that item

string assetID

ID of the asset:

  • BackpackItem: The itemID found in Spatial Studio
  • Package: The packageSKU found in Spatial Studio or Unity
  • EmbeddedAsset: The assetID specified in the UnitySDK.Editor.SpaceConfig in Unity Editor
bool equip

Should it be equipped or not

bool clearOccupiedPrimarySlot

When equipping, should any conflicting primary slot be cleared, or should this equip additively on top of the existing attachments? Used when equip is set to true

string optionalTag

A string tag that can be used to reference some attachments. Used by ClearAttachmentsByTag

Examples

public void ToggleSwordEquipped()
{
IAvatar localAvatar = SpatialBridge.actorService.localActor.avatar;

if (localAvatar.IsAttachmentEquipped("SwordAttachment"))
{
localAvatar.ClearAttachmentSlot(SpatialAvatarAttachment.Slot.RightHand);
}
else
{
localAvatar.EquipAttachment(AssetType.EmbeddedAsset, "SwordAttachment");
}
}
public void ToggleSwordEquipped()
{
IAvatar localAvatar = SpatialBridge.actorService.localActor.avatar;

if (localAvatar.IsAttachmentEquipped("SwordAttachment"))
{
localAvatar.ClearAttachmentSlot(SpatialAvatarAttachment.Slot.RightHand);
}
else
{
localAvatar.EquipAttachment(AssetType.EmbeddedAsset, "SwordAttachment");
}
}