[BUG]: MagicParticle.OnParticleCollision: m_MagicItem Object reference not set

echtnice

Member
Hi,

I've implemented a new magic spell which uses the SpawnParticle Cast action with a ParticleSystem. The ParticleSystem has the following components: MagicParticle, ParticlePooler, PhotonView, and PunMagicParticle.

When player 1 casts the magic spell, I noticed the following exception being thrown by player 2:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Objects.ItemAssist.MagicParticle.OnParticleCollision (UnityEngine.GameObject other) (at Assets/Opsive/UltimateCharacterController/Scripts/Objects/ItemAssist/MagicParticle.cs:106)

Must the PunMagicParticle initialize MagicParticle like PunMagicProjectile/MagicProjectile?

Adding the following seems to fix the NullReferenceException for me at least ...

PunMagicParticle:ObjectSpawned:96
Code:
            var magicParticle = gameObject.GetCachedComponent<MagicParticle>();
            if (magicParticle != null) {
                magicParticle.Initialize(magicItem, (uint)photonView.InstantiationData[4]);
            }

Thanks!
 
Top