Several bugs and feature request.

Ascendance Games

New member
Bug: KinematicObjectManager is clearing some abilities cache when scene is unloaded but not rebuilding when scene reloads.
On line Line 948 within KinematicObjectManager.
KinematicObjectManager is clearing some abilities cache when scene is unloaded but not rebuilding when scene reloads. In result character abilities are null when UltimateCharacterLocomotion calls Awake on abilities.


Bug: SpawnPoint(s) will add multiple instances to SpawnPointManager as well add at wrong indexes if `int Grouping` value is set before SpawnPoint OnEnable runs.

Code:
///Hackish fix: add initialized check.
        private void OnDisable()
        {
            SpawnPointManager.RemoveSpawnPoint(this);
            m_initialized = false;
        }
        private void OnEnable()
        {
            SpawnPointManager.AddSpawnPoint(this);
            m_initialized = true;
        }

        public int Grouping
        {
            get { return m_Grouping; }
            set
            {
                if (m_Grouping != value) {
                    // The SpawnPointManager needs to be aware of the change so it can update its internal mapping.
                    if (Application.isPlaying && m_initialized) {
                        SpawnPointManager.UpdateSpawnPointGrouping(this, value);
                    }
                    m_Grouping = value;
                }
            }
        }


Feature: SpawnPoint(s) should be accessible in the SpawnPointManager. Here's a handy accessor which can return them, with options.
Code:
        /// <summary>
        /// Returns a list of spawn points.
        /// </summary>
        /// <param name="grouping">Grouping of spawn points to return. If not specified all spawn points are returned.</param>
        /// <returns></returns>
        public static List<SpawnPoint> ReturnSpawnPoints(int? grouping = null)
        {
            return Instance.ReturnSpawnPointsInternal(grouping);
        }
        /// <summary>
        /// Returns a list of spawn points.
        /// </summary>
        /// <param name="grouping">Grouping of spawn points to return. If not specified all spawn points are returned.</param>
        /// <returns></returns>
        private List<SpawnPoint> ReturnSpawnPointsInternal(int? grouping = null)
        {
            if (grouping == null)
            {
                return m_SpawnPoints;
            }
            else
            {
                if (grouping.Value != -1)
                {
                    List<SpawnPoint> results;
                    if (!m_SpawnPointGroupings.TryGetValue(grouping.Value, out results))
                        Debug.LogError("Error: Unable to find a spawn point with the grouping index " + grouping);

                    return results;
                }
                else
                {
                    return m_SpawnPoints;
                }
            }
        }
Code:
//within GetPlacementInternal can replace
            List<SpawnPoint> spawnPoints;
            if (grouping != -1)
            {
                if (!m_SpawnPointGroupings.TryGetValue(grouping, out spawnPoints))
                    Debug.LogError("Error: Unable to find a spawn point with the grouping index " + grouping);
            }
            else
            {
                spawnPoints = m_SpawnPoints;
            }
//with
List<SpawnPoint> spawnPoints = ReturnSpawnPointsInternal(grouping);

Feature: Abilities should have an additional start option as "Button Not Held". In such scenarios ability would run long as button is not held, and stop when button is held, then resume again when not held.

*edit: fixed typos*
 
Last edited:

Justin

Administrator
Staff member
Bug: KinematicObjectManager is clearing some abilities cache when scene is unloaded but not rebuilding when scene reloads.
On line Line 948 within KinematicObjectManager.
KinematicObjectManager is clearing some abilities cache when scene is unloaded but not rebuilding when scene reloads. In result character abilities are null when UltimateCharacterLocomotion calls Awake on abilities.
I have a test scene that does a scene reload and it seems to work. Are you persisting the character across scene changes? If so make sure you also persist the game components, camera, and ui.

Thanks for the spawn manager suggesions.

Feature: Abilities should have an additional start option as "Button Not Held". In such scenarios ability would run long as button is not held, and stop when button is held, then resume again when not held.


Feature: Abilities should have an additional start option as "Button Not Held". Uses: I want to enable Aim when Sprint isn't held.
For these you should be able to use a custom start type and define when your ability starts:

 

Ascendance Games

New member
Justin, in addition the ability starter maybe isn't what I'm looking for.
I tried this,

Code:
    public override bool CanInputStartAbility(PlayerInput playerInput)
    {
        return !playerInput.GetButton(_inputName);
    }
Trying to have it set Aim state and it simply wouldn't work.
Automatic as the AbilityStarter works fine, but there is no option to stop an ability while a button is held. Button Down only works for 1 frame, of course.
 

Justin

Administrator
Staff member
All UCC related objects are destroyed on scene changes.
Can you send me a small repro scene that shows the error that you are receiving? Also, what version of Unity are you using? You only need to send me the unique assets and not the actual UCC package.
Automatic as the AbilityStarter works fine, but there is no option to stop an ability while a button is held. Button Down only works for 1 frame, of course.
Ah, yeah, in that case it needs to have a custom stop. I have written it down to allow for a custom stop similar to how there is a custom start.
 

Ascendance Games

New member
Can you send me a small repro scene that shows the error that you are receiving? Also, what version of Unity are you using? You only need to send me the unique assets and not the actual UCC package.

Ah, yeah, in that case it needs to have a custom stop. I have written it down to allow for a custom stop similar to how there is a custom start.
Well, all I need now is that custom stop action please! I solved the abilities cache issue.

In KinematicObjectManager you are subscribing to SceneUnloaded with OnDisable, and unsubscribing with OnEnable. You also unsubscribe in the event called from scene unloaded.

The resolution requires you to remove sub/unsub from OnEnable, OnDisable, and on event. Then subscribe on Awake and unsubscribe OnDestroy.
 

Justin

Administrator
Staff member
Glad you were able to get it working. I'll take a look at those changes (version 2.1.8 just went out so it won't be in that).
 

Justin

Administrator
Staff member
The resolution requires you to remove sub/unsub from OnEnable, OnDisable, and on event. Then subscribe on Awake and unsubscribe OnDestroy.
I'm circling around to this and looked into this further. By changing the KinematicObjectManager to this setup the SceneChange callback is never called. I think that I found the root of the problem though. Within UnityEngineUtility change line 49 from:
Code:
                if (s_LoadedAssemblies == null) {
to:
Code:
                if (s_LoadedAssemblies == null || s_LoadedAssemblies.Count == 0) {
This should correctly reload the cache when the scene is loaded again.
 
Top