UCC version: 3.0.15
When my character dies the perspective monitor is throwing a blocking null ref from the renderers in TryUpdateDeathMaterials().
Its probably something we caused since we only want a specified number of weapons on a character at a time and we need them to be fully destroyed when unequipped so we have a custom inventory that does this, but the perspective monitor doesn't clean up the renderers list when its removed.
There is probably two approaches to fix and make the perspective monitor more error proof.
The easy: Check if the renderer is null before trying to set the materials, this should work for any use-cases and no extra overhead. This is what I have done for now.
The robust: Remove renderers from the list when they are unequipped, this might not be feasible for some use-cases if items are unequipped but still supposed to be visible.
When my character dies the perspective monitor is throwing a blocking null ref from the renderers in TryUpdateDeathMaterials().
Its probably something we caused since we only want a specified number of weapons on a character at a time and we need them to be fully destroyed when unequipped so we have a custom inventory that does this, but the perspective monitor doesn't clean up the renderers list when its removed.
C#:
private bool TryUpdateDeathMaterials(bool fromDeathEvent)
{
// Ensure no first person weapons are equipped before enabling the third person objects.
if (m_CharacterLocomotion.FirstPersonPerspective) {
for (int i = 0; i < m_Inventory.SlotCount; ++i) {
if (m_Inventory.GetActiveCharacterItem(i) != null) {
// If an item is still equipped then the material shouldn't be switched until after it is no longer equipped.
if (fromDeathEvent) {
EventHandler.RegisterEvent<CharacterItem, int>(m_GameObject, "OnInventoryUnequipItem", OnUnequipItem);
}
return false;
}
}
}
// All items are unequipped. Update the renderers.
for (int i = 0; i < m_Renderers.Count; ++i) {
var invisibleObject = false;
if (m_DeathVisibility == ObjectDeathVisiblity.AllInvisible) {
invisibleObject = m_CharacterLocomotion.FirstPersonPerspective;
} else if (m_DeathVisibility == ObjectDeathVisiblity.ThirdPersonObjectDetermined) {
var thirdPersonObject = m_RendererThirdPersonObjects[i];
invisibleObject = m_CharacterLocomotion.FirstPersonPerspective &&
(thirdPersonObject != null && !thirdPersonObject.FirstPersonVisibleOnDeath && !thirdPersonObject.ForceVisible);
}
//Throws null here
m_Renderers[i].materials = (invisibleObject ? m_InvisibleMaterials[i] : m_OriginalMaterials[i]);
}
return true;
}
There is probably two approaches to fix and make the perspective monitor more error proof.
The easy: Check if the renderer is null before trying to set the materials, this should work for any use-cases and no extra overhead. This is what I have done for now.
The robust: Remove renderers from the list when they are unequipped, this might not be feasible for some use-cases if items are unequipped but still supposed to be visible.