Hang ability not properly aligning after changing character model.

jaunger1999

New member
Hi,

I've been experimenting with exchanging the character model within my character and encountered an issue with the hang ability.

What I've changed.

1. I moved a new character model and rig into the character object.
2. I moved the items held in the previous rig to the new rig.
3. I removed the previous model and rig.
4. I changed the avatar to match the new model/rig.

Firstly, all animations and abilities I've added work except for hang.

Two issues arise as a result of this.
1. The character no longer properly aligns themself with the object they're hanging on. They clip into the object and move along according to the angle they started the ability with.
2. An index out of bounds error in the item set base that occurs if I haven't picked anything up.

Would I be better off creating a new character and copying my components over? Or is this a fixable issue?

Thanks
 
Last edited:
This is the error I received.

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <695d1cc93cca45069c528c15c9fdd749>:0)
Opsive.UltimateCharacterController.Inventory.ItemSetManagerBase.IsDefaultItemCategory (Opsive.Shared.Inventory.ItemDefinitionBase itemDefinition, Opsive.Shared.Inventory.IItemCategoryIdentifier itemCategory) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/ItemSetManagerBase.cs:198)
Opsive.UltimateCharacterController.Inventory.ItemSetManagerBase.IsDefaultItemCategory (Opsive.Shared.Inventory.ItemDefinitionBase itemDefinition, Opsive.Shared.Inventory.IItemCategoryIdentifier itemCategory) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/ItemSetManagerBase.cs:169)
Opsive.UltimateCharacterController.Inventory.ItemSetManagerBase.IsDefaultItemCategory (Opsive.Shared.Inventory.ItemDefinitionBase itemDefinition) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/ItemSetManagerBase.cs:155)
Opsive.UltimateCharacterController.Character.Abilities.ItemEquipVerifier.IsDefaultItemIdentifier (Opsive.Shared.Inventory.IItemIdentifier itemIdentifier) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/ItemEquipVerifier.cs:220)
Opsive.UltimateCharacterController.Character.Abilities.ItemEquipVerifier.TryToggleItem (Opsive.UltimateCharacterController.Character.Abilities.Ability ability, System.Boolean activate) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/ItemEquipVerifier.cs:109)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability, System.Boolean ignorePriority, System.Boolean ignoreCanStartCheck) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1176)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability, System.Boolean ignorePriority) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1080)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1069)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:235)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.UpdateAbilityInput (Opsive.UltimateCharacterController.Character.Abilities.Ability[] abilities) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:131)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.UpdateAbilityInput () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:98)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.Update () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotionHandler.cs:73)
 
For the first one you'll need to adjust the offsets to account for your new character rig. This page has more explanation:


For the second one what line is null? It doesn't look like my line numbers are matching up.
 
I had a feeling it had to do with those offset values you mentioned. I managed to fix the first issue by setting the y value in "Relative Hang Offset" to 0 but I still want to understand better. Maybe I'm missing something but the documentation doesn't seem clear to me here.

In particular,

Relative Hang Offset​

The offset from the top of the character to the hang object.
Does the top refer to the hands while the character is hanging? Or their head?

Draw Debug Lines​

Should debug lines be drawn to the editor indicating the location of the horizontal and vertical casts?
Does "in the editor" mean in the scene or in the game view? I can't see anything in either with this enabled.

How do you find these offset values for a given model? I would imagine the minimum and maximum start offset could be found with "Draw Debug Lines" enabled but "Relative Hang Offset" confuses me.

As for the second issue, the line in question seems to be 187 in the ItemSetManagerBase class,

var itemSetList = m_CategoryItemSets[index].ItemSetList[m_ActiveItemSetIndex[index]];

I set a breakpoint here and caught the IndexOutOfBounds exception in action.
m_CategoryItemSets[index].ItemSetList has a count of 0 and index is set to 1.

The issue only occurs with frag grenades equipped. I thought this issue only came up after changing the character model but now I realize it was there beforehand.

Thank you for your help btw Justin. I hope my questions aren't too frustrating. This system has quite the learning curve to it but seems really great so far.
 
Does the top refer to the hands while the character is hanging? Or their head?
It's relative to the position that was hit on the hang object:
Code:
                var targetPosition = MathUtility.TransformPoint(m_RaycastResult.point, raycastRotation, m_RelativeHangOffset);

So for example if the hang object was detected at a y value of 2, this would push the character down by the specified offset amount.

Does "in the editor" mean in the scene or in the game view? I can't see anything in either with this enabled.
It's in the scene view. Make sure you have gizmos enabled.

How do you find these offset values for a given model? I would imagine the minimum and maximum start offset could be found with "Draw Debug Lines" enabled but "Relative Hang Offset" confuses me.
Relative Hang Offset is best found by having your character hang and then adjusting the values at runtime.

The issue only occurs with frag grenades equipped. I thought this issue only came up after changing the character model but now I realize it was there beforehand.
Thanks, just above that line go ahead and add:

Code:
            if (m_CategoryItemSets[index].ItemSetList.Count < m_ActiveItemSetIndex[index]) {
                return false;
            }
 
Top