ObjectFader Exception

It happens when I launch the rocket with the Rocket Launcher. The rocket seems to fly but the explosion is only exploding 2 times of 17.


ArgumentException: An item with the same key has already been added. Key: RocketLauncher (Instance) (UnityEngine.Material)
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
Opsive.UltimateCharacterController.ThirdPersonController.Camera.ObjectFader.InitializeCharacterFadeRenderers (UnityEngine.Renderer[] renderers) (at Assets/Opsive/UltimateCharacterController/ThirdPersonController/Scripts/Camera/ObjectFader.cs:602)
Opsive.UltimateCharacterController.ThirdPersonController.Camera.ObjectFader.OnShowProjectile (UnityEngine.GameObject projectile, System.Boolean show) (at Assets/Opsive/UltimateCharacterController/ThirdPersonController/Scripts/Camera/ObjectFader.cs:625)
Opsive.UltimateCharacterController.Events.InvokableAction`2[T1,T2].Invoke (T1 arg1, T2 arg2) (at Assets/Opsive/UltimateCharacterController/Scripts/Events/InvokableAction.cs:132)
Opsive.UltimateCharacterController.Events.EventHandler.ExecuteEvent[T1,T2] (System.Object obj, System.String eventName, T1 arg1, T2 arg2) (at Assets/Opsive/UltimateCharacterController/Scripts/Events/EventHandler.cs:425)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.DetermineVisibleProjectile (System.Boolean forceDisable) (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:823)
Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon.ShowReloadProjectile () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Actions/ShootableWeapon.cs:1402)
Opsive.UltimateCharacterController.Game.ScheduledEvent.Invoke () (at Assets/Opsive/UltimateCharacterController/Scripts/Game/Scheduler.cs:80)
Opsive.UltimateCharacterController.Game.Scheduler.Invoke (Opsive.UltimateCharacterController.Game.ScheduledEventBase scheduledEvent, System.Int32 index) (at Assets/Opsive/UltimateCharacterController/Scripts/Game/Scheduler.cs:657)
Opsive.UltimateCharacterController.Game.Scheduler.FixedUpdate () (at Assets/Opsive/UltimateCharacterController/Scripts/Game/Scheduler.cs:329)
 
This has been fixed in 2.1, but it relates to not having the materials cached. Until 2.1 is released if you keep Cache Character Materials enabled then it should work.
 
It's already cached. I'll wait til 2.1
One more thing, I get problems with my own explosions. They work fine but when I instantiate with Opsive pool system & weapons (grenade, rocket, etc..) they work just sometimes, I wonder if is because the pooling system, that doesn't allow the start / awake code to run...
I leave you here the code of one of them just in case you can tell me something:

This component is at the root of the prefab and starts calling the effects with the IEnumerator. Sometimes instead of explode with all the effects just works with some of them. If I just disable / enable on the editor (even when is in the hierarchy on your pool work fine, but when they are instantiate with opsive weapons only works sometimes.)

using UnityEngine;
using System.Collections;

public class ExplosionStart : MonoBehaviour
{
public ParticleSystem ExplodeVideoParticles;
public ParticleSystem ExplodeVideoParticles_Ground;
public ParticleSystem SmokeParticles;
public ParticleSystem SparkParticles;
public Light ExplodeLight;
public AudioSource ExplodeAudio;
public GameObject ScorchMark;

private float fadeStart = 30;
private float fadeEnd = 0;
private float fadeTime = 1;
private float t = 0.0f;
private float pauseTime = 0;

private void Start()
{
Detonate();
}

public void Detonate()
// Detonate
{
ExplodeVideoParticles.Play();
ExplodeVideoParticles_Ground.Play();
SmokeParticles.Play();
SparkParticles.Play();
ExplodeAudio.Play();
ScorchMark.SetActive(true);

pauseTime = 0;

StartCoroutine("FadeLight"); // Explosion Light
}

public void PauseExposion()
// Pause
{
SparkParticles.Pause();
ExplodeVideoParticles.Pause();
ExplodeVideoParticles_Ground.Pause();
SmokeParticles.Pause();
pauseTime = 1;
}

IEnumerator FadeLight()
{
while (t < fadeTime)
{
if (pauseTime == 0)
{
t += Time.deltaTime;
}

ExplodeLight.intensity = Mathf.Lerp(fadeStart, fadeEnd, t / fadeTime);
yield return 0;
}
t = 0;
}
}
 
Top