ItemSetManager

Chibizzle

New member
I have 2 characters in my game. A player and an enemy with BehaviorDesigner.
However the player (left) has instantiated all the correct items in its ItemSetManager unlike the enemy (right).

1595328473256.png1595328415320.png

To create the enemy I did the followwing:
- I used the UCC character creator with AI Agent and NavMeshAgent enabled.
- Then I used the PUN integration script on it
- Removed the Respawner scripts
- Added BehaviorTreeAgent
- I have also tried with and without DemoAgent script supplied in the demo

I checked and both of their ItemSetManagers are being initialized in code.
It might also be worth noting that the player is being spawned with a SpawnBaseManager script, but the enemy is spawned with a custom script:
Is this the correct way to spawn a non-player object over PUN?

Code:
using Opsive.Shared.Game;
using Opsive.UltimateCharacterController.Networking.Game;
using Opsive.UltimateCharacterController.Utility;
using Photon.Pun;
using UnityEngine;

namespace Chib
{
    public class SpawnEnemy: MonoBehaviour
    {
        [Tooltip("The enemy that should be spawned.")]
        [SerializeField] protected GameObject m_Enemy;
        [Tooltip("The positional offset that the object should be spawned.")]
        [SerializeField] protected Vector3 m_PositionOffset;
        [Tooltip("The rotational offset that the object should be spawned.")]
        [SerializeField] protected Vector3 m_RotationOffset;
        [Tooltip("Should the object be parented to the origin?")]
        [SerializeField] protected bool m_ParentToOrigin;
        private GameObject m_SpawnedObject;

        public void Start() {
            if (!PhotonNetwork.IsMasterClient) {
                return;
            }

            if (m_Enemy == null) {
                Debug.LogError("Error: An Enemy must be specified.");
                return;
            }
            
            var position = MathUtility.TransformPoint(transform.position, transform.rotation, m_PositionOffset);
            m_SpawnedObject = ObjectPool.Instantiate(m_Enemy, position, Quaternion.Euler(m_RotationOffset), m_ParentToOrigin ? transform : null);

#if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER
            NetworkObjectPool.NetworkSpawn(m_Enemy, m_SpawnedObject, false);
#endif
        }
    }
}


What am I missing to achieve a filled ItemSetManager like the one with the Player?
 
Are you running the latest version? There were some ItemSetManager initialization changes in 2.2.4.
 
Can you place a breakpoint within ItemSetManager.Initialize and see why it is initializing the Item Collection to a set of null objects? The Category Item Sets array should be populated with each Item Collection category.
 
EDIT: This also happens for the player character, which does load the ItemSet correctly as shown in my first message...
So now I'm really confused :(

EDIT2: It seems like m_ItemCollection DOES load the ItemTypes, but they're not being put on the m_CategoryItemSet.ItemSetList

// The ItemTypes get their categories from the ItemCollection.
for (int i = 0; i < m_ItemCollection.ItemTypes.Length; ++i) {
m_ItemCollection.ItemTypes.Initialize(m_ItemCollection);
}

-----------------------


I can see that the m_ItemSetList in the categories are empty

1595501188654.png

I tried to trace to where they are set, but I could only find ItemSetList.Add in the ItemBuilder.
 

Attachments

  • 1595501150306.png
    1595501150306.png
    53.1 KB · Views: 4
Last edited:
It looks like CategoryItemSet is not empty so that's good. Since you already have the Item Set created within the Item Set Manager you won't see it being called from the Item Builder. On line 78 of your screenshot are there Item Sets? Do they get initialized?

Taking another approach, are you able to reproduce it within the demo scene of a fresh project?
 
Line 78 never gets triggered, because ItemSetList is always empty

Apparently it was the RuntimePickups script that filled the ItemSetManager of the player character when a Player had entered the room.
My expectation was an event triggered that filled all of the managers on spawn.
Now that I have put the ItemSetManager like the one in the Demo, the only thing that wont happen is the weapon being equipped. Equipping the weapon should trigger the PUN script so it would be sent over the network.

Isn't it supposed to be default behavior, that when a default loadout is selected it should be equipped when the character initialized?

I tried by a adding a script that gets the EquipUnequip ability and calls StartEquipUnequip in the Start() method. This does set the active item in ItemSetManager, but I do not see the NPC equip its gun.

I then tried with Behavior Designer with the Start Equip Unequip action, but I cannot enter the categoryId. It's not possible to select from the regular itemset dropdown as shown in the image below. So this I couldnt get working to test eqipping with. In debug mode i found that the categoryId was supposedly generated as 3956536178. is this perhaps the problem? Did something not go well with the migration?

1595973479604.png
 
Last edited:
If StartEquipUnequip doesn't equip the item then the Behavior Designer task won't either. I'm guessing that the dropdown doesn't show because you don't have the behavior tree on the character with the ItemSetManager.

I would instead debug why StartEquipUnequip doesn't pick up the item - you can place a breakpoint and then see why it ends early. This should lead you to the source of the issue.
 
Top