How do we equip Armor ?

"Tried following this from another post, but still have issues"

The Character Controller Inventory does not support character skinned mesh items. Clothes and armor must be equipped through the Ultimate Inventory System. The easiest way to do so is by using the Equipper script.
Since armor and weapons will be equipped through different systems the clothes cannot be equipped with an “Equippable” ItemCollection, these are meant to be used purely for the Character Controller weapons. Therefore another ItemCollection must be used for clothes and armor.

  1. Create a new ItemSlotCollection for your armor and name it accordingly (i.e “Armor Equipped”), set its purpose to “None” such that it won’t be confused with the “Equippable” collections.
  2. Create an ItemSlotSet for your armor slots and assign it to your new ItemSlotCollection.
  3. Add an Equipper script to your character, assign the ItemSlotSet and define which slots are skinned mesh.
  4. Create an additional Equipment UI (aka ItemSlotCollectionView) separate from the weapons equipment UI. Make sure that each are set up correctly and point to the correct ItemSlotCollections.
  5. Use the MoveToItemCollection Item Action for equipping the armor in the UI and make sure the correct ItemCollection name is specified, The CharacterEquipItemAction should only be used for equipping “Equippable” Character Controller weapons.
  6. Create items with skinned mesh prefabs following the Equipper guidelines for skinned mesh equipments.
Since your armor and weapon items will be separated in two or more item collections you may wish to create an Item Collection Group to keep track of all your equipment in code.

The Equipper script is fairly simple, you may extend it or replace it with your own custom script to make it more advanced.
 

Sangemdoko

Moderator
Staff member
Hi myles.

Could you tell me what your issues are? Do you have errors, warnings? Are equipment items equipped but in the wrong place? Are the item spawned on the character hierachy but they don't appear in game? Are your skinned equipment items skinned with the exact same bone hierachy as your character rig?

I personally thought the instructions you posted above and this video from the other forum post you mentioned: https://streamable.com/3jig9d
where quite clear. But perhaps your use case is slightly different.

Once you give me more information about what issue you are having I can try to improve the documentation.
 

Sangemdoko

Moderator
Staff member
Thanks.

So first I see is that you have a lot of errors, these might be unrealted to UIS/UCC, but I would highly recommend you fix those one by one starting from the top. One error can ripple through and cause issues to other systems event if they aren't realated, especially if those errors happen in Awake, Start or Update.

Make sure to read the error messages since they can help you understand where the error came from and why. For example I can see a that your item slot collection UI does not point to the correct collection because the slot set don't match.

1) For the Bow: it's weird how when you pull the bow string there is still a string there. Are you spawning two bows by mistake? The arow should draw back with the string if you add an ObjectIdentifier with the correct ID 4 on the characters right hand. I believe that should have been explained on the video tutorial on setting up a Bow

2) Your sword attacks, This happen when the IK isn't setup properly or a state preset isn't set. Make a seperate post about it in the UCC only forum category and someone should be able to guide you more precisly

3) For equipping Armor.

Your Armor shouldn't be part of the "Equippable" category. The Equippable Category is meant of Equippable items that use the integration with UCC. Feel free to rename it to WeaponEquippable and have another category called "WeaponEquippable".

My guess is that you can't see the item being equipped in your equipment UI because you haven't set the correct Collection ID (the collection name) in the Equipment UI (aka ItemSlotCollectionView). You need to specify what collection your UI is monitoring.

Your Item Action might be the issue as to why you aren't equipping the item. Your Second Collection ID should be "ArmorEquipped". and not Purpose Equipped which is your Weapon Equippable collection.

Your Armor prefab doesn't need an Item component, etc... because it is not a UCC Item (weapon). It can simply be a skinned mesh.

You cannot convert a simple Mesh to a skinned mesh. You need to properly set your 3D Model in a 3D software and paint the bone weigths and apply them. When you import it in Unity the Model should automatically be set as a Skinned Mesh (You may need to set your Armor rig as a "Humanoid"). You cannot simply replace a Mesh Renderer by a SkinnedMeshRendrer in Unity dirrectly. You can't even modify the bone hierachy or remove it when a mesh is skinned or the verteces won't know what to do and the item will disapear. The only way to set an skinned mesh on another skinned mesh with the sam hierachy is through code (it only works if the hiearchy of bones are the exact same). This is done at runtime in the Equipper script. You should perhaps look some tutorials on how to import skinned meshes if you aren't sure what I mean.

You ItemDefinition must have an attribute with the Armor Prefab otherwise the Equipper won't know what to spawn. You can specify what name that attribute should have in the Equipper component.

I hope that helps, do let me know if you are still struggling with this.
 
I am very mush struggling with this

Putting everything else to one side just focusing on "equipping Armor".

Firstly
"Your Armor shouldn't be part of the "Equippable" category. The Equippable Category is meant of Equippable items that use the integration with UCC. Feel free to rename it to WeaponEquippable and have another category called "WeaponEquippable"." I assume you just meant Armor to differentiate between the two of them. that's fine, but really was not clear before and needs to be highlighted for others.

Secondly,
My guess is that you can't see the item being equipped in your equipment UI because you haven't set the correct Collection ID (the collection name) in the Equipment UI (aka ItemSlotCollectionView). You need to specify what collection your UI is monitoring.

are you referring to this ? They work for Weapons, but not the Armor, and I don't know why, but both look like they are setup correctly.
It worked previously when I had just the one collection, but splitting them lead to this issue occurring
1630328431722.png

Thirdly -
The guidance above said to create a New Item action set with the "Move To Collection Item Action" for Equipping, which I have done here.
1630329053250.png

I don't see the issue here with the Armour purpose, they are both set to "None"
1630328568066.png
 
I just found this, do these need to also match ?

or is it only for the weapons as they are using the Integration with the UCC ?

1630329564694.png

Its also complaining about the two Item Slot sets together
1630330373075.png
 
Last edited:

Sangemdoko

Moderator
Staff member
Here are some screenshots from the video you recorded. I highlited the problems I could spot:
1630338004506.png
That Equip Item Action should point to "Armor Equipped"

I think the error you are getting is related to this:
1630338077707.png

My guess is that your ITem Collection ID is not pointing to the correct ItemCollection you are trying to monitor



As for your question:
or is it only for the weapons as they are using the Integration with the UCC ?
That's only for UCC Equippables, you armor should be part of that list of collections. Most if not all things related to the Character Inventory Bridge are related to UCC Equippable items/weapons
 
HI

how are the Item Collections Id's meant to be setup ?

Should the ID collections be like this (With the Armour being the second Item collection Id and the Inventory being the first)?

1630364141593.png

is this or the next one correct ?
1630364316133.png

comparing the Inventory scrip on the character I would expect this to be correct as seen in the next post screenshot

1630407432605.png
 
Last edited:

Sangemdoko

Moderator
Staff member
Your Item Collection IDs are correct now.

The way they work is they will try to find an ItemCollection with the exact same name. If you do not specify the name but just the purpose then it will try to find the first collection that has the same purpose.

Do I need to do anything with the Inventory Item set manger script or is this only for Weapons ?
The Inventory Item Set Manager is part of the integration and is only used for weapons (UCC Equippables)
 
I am still getting issues

The armour does not equip and the Item action no longer works for the weapons. I can only drag and drop them, but they do move equip if i select equip


apologies the sound is terrible
 

Sangemdoko

Moderator
Staff member
I can't really tell what the issue is from your video.

You have two Equip Item Actions, one for your weapon and one for your armor, which is correct. Just double check that they are both setup correctly and trying to equip to the correct collection using the correct item action (CharacterEquipUnequipItemAction for weapons and MoveToItemCollection for armor).

Then double check your UI to see if you are correctly referencing your ItemViewSlot in the correct container.

You can open you Inventory Inspector at runtime to see where your items are. Check to see if your items are in the correct collection. If they are the issue might just be in the UI and if not then the issue may be the item action.

You can always add some Debug.Logs in the source code to try and understand where your issue is.
 
I had to make some changes in the "Character Inventory Bridge,

I removed the Armor collection from the list of Item collections (and the other defaults I was not using), but I don't know if this is an issue or just a setting, its not going blue when equipped and when it loads in with the Armor on, I have to unequip it and equip it before it show up.

I assume this is because its not using the character system just the inventory system

Strangely this made my shields and my bow move completely out of position, when they are equipped, its really strange,

1630449213732.png

1630449171889.png
 
I think I found a bug:

If you start playing whist armour is already equipped on the character, it displaces the weapons but attaching to the position relative to the armour

Here you can see my weapons being attached to the Armour Instead of the character rig (from keeping the rig on the Armor) which has made it float

1630496136574.png
 
Last edited:

Sangemdoko

Moderator
Staff member
That's an interesting bug...
Why do you have an "Items" game object in your Armor rig? When I said the the armor should have the exact same rig as the character I meant the exact same animation rig (The rig it the model). And the armor rig should not be changed in Unity at all, it should be as is coming from the 3D software where it was weight painted. Note that this is not a constraint on our system, that's just how Unity works with skinned meshes.

To be fair the armor rig doesn't need to exist after it is spawned since it is bound to the character rig. I've changed some code in the Equipper and ItemObjectSlot scripts to remove the "previous/original" root of the armor. That should avoid similar problems in the future.

Here is the change in the Equipper script:
Code:
/// <summary>
/// Return the Item Object to the pool.
/// </summary>
/// <param name="itemObject">The itemObject to return.</param>
protected virtual void ReturnItemObjectToPool(ItemObject itemObject)
{
    //Unset the skinned bones
    var skinnedMeshes = itemObject.GetComponentsInChildren<SkinnedMeshRenderer>();
    for (int i = 0; i < skinnedMeshes.Length; i++) {
        skinnedMeshes[i].rootBone = null;
        skinnedMeshes[i].bones = null;
    }
    
    //The itemObject could have children that are pooled object such as the equipment model.
    for (int i = itemObject.transform.childCount - 1; i >= 0; i--) {
        if ((ObjectPool.IsPooledObject(itemObject.transform.GetChild(i).gameObject) == false)) { continue; }
        ObjectPool.Destroy(itemObject.transform.GetChild(i).gameObject);
    }
    ObjectPool.Destroy(itemObject.gameObject);
}

And this is the change in the ItemObjectSlot

Code:
/// <summary>
/// Set the item object.
/// </summary>
/// <param name="itemObject">The item object.</param>
/// <param name="mainSkinnedMeshRenderer">The skinned Mesh Renderer for the item object.</param>
public virtual void SetItemObject(ItemObject itemObject, SkinnedMeshRenderer mainSkinnedMeshRenderer)
{
    m_ItemObject = itemObject;
    HideDefaultGameObjects(m_ItemObject != null);
    if (m_ItemObject == null) { return; }
    if (!m_IsSkinnedEquipment) {
        return;
    }
    var itemTransform = m_ItemObject.transform;
    itemTransform.SetParent(mainSkinnedMeshRenderer.transform.parent);
    itemTransform.localPosition = Vector3.zero;
    itemTransform.localRotation = Quaternion.identity;
    itemTransform.localScale = Vector3.one;
    SkinnedMeshRenderer[] equipmentSkinnedMeshRenderers = m_ItemObject.GetComponentsInChildren<SkinnedMeshRenderer>();
    for (var i = 0; i < equipmentSkinnedMeshRenderers.Length; i++) {
        SkinnedMeshRenderer equipmentSkinnedMeshRenderer = equipmentSkinnedMeshRenderers[i];
        if (equipmentSkinnedMeshRenderer.rootBone != null && equipmentSkinnedMeshRenderer.rootBone != mainSkinnedMeshRenderer.rootBone) {
            GameObject.Destroy(equipmentSkinnedMeshRenderer.rootBone.gameObject);
        }
        
        equipmentSkinnedMeshRenderer.rootBone = mainSkinnedMeshRenderer.rootBone;
        equipmentSkinnedMeshRenderer.bones = mainSkinnedMeshRenderer.bones;
    }
}

Essentially this change removes the rig that the armor prefab came with and makes sure that even when the armor is pooled it won't cause any issues.
 
Top