Healthkit

Options
Basically i have this healthkit problem , when i make room and join that map first time it picks up health kit normally all good but when i leave room and make room again healthkits are not giving health they're destroyed on pickup btw it destroys but it doent give health at second time.
MissingReferenceException: The object of type 'bl_PlayerDamageManager' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
UnityEngine.Component.GetComponent[PhotonView] () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineComponentBindings.gen.cs:48)
PhotonView.Get (UnityEngine.Component component) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:652)
Photon.MonoBehaviour.get_photonView () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonClasses.cs:460)
bl_PlayerDamageManager.OnPickUp (Single amount) 
bl_EventHandler.PickUpEvent (Single t_amount) 
bl_MedicalKit.OnTriggerEnter (UnityEngine.Collider m_other)

Comments

  • Geoboy
    Options
    Bump?
  • Hi,

    basically, it's because you are trying to access ti when it's already destroyed, you should check for ==null on your variable before using it.

    Is that the whole error log? it's very odd in its format especially the last three lines.

    To me it looks like you are not cleaning up properly your scene on load when your scene was already loaded. Maybe you have duplicates?

    how do you create these healthkit GameObject, are they instantiated at runtime or they are int he scene during editing?

    Bye,

    Jean
  • Geoboy
    Options
    bl_PlayerDamageManager.OnPickUp (Single amount) (at Assets/FPS/Scripts/Network/bl_PlayerDamageManager.cs:547)
    bl_EventHandler.PickUpEvent (Single t_amount) (at Assets/FPS/Scripts/Internal/Events/bl_EventHandler.cs:69)
    bl_MedicalKit.OnTriggerEnter (UnityEngine.Collider m_other) (at Assets/FPS/Scripts/Misc/bl_MedicalKit.cs:73)
    those are last three lines, healthkits are on scene this is line of medicalkit:73
        void OnTriggerEnter( Collider m_other)
        {
            if (m_other.transform.tag == bl_PlayerSettings.LocalTag)
            {
                bl_PlayerDamageManager pdm = m_other.transform.root.GetComponent<bl_PlayerDamageManager>();
                if (pdm.health < pdm.maxHealth)
                {
                    if (typekit == 1)
                    {
                        if (!Alredy)
                        {
    						Alredy = false;
                            bl_EventHandler.PickUpEvent(m_amount);
                        }
                        if (m_manager != null)
                        {
                            m_manager.DisableNew(m_id);
                        }
                    } if (typekit == 2)
                    {
                        if (!Alredy)
                        {
    						Alredy = false;
                            bl_EventHandler.PickUpEvent(m_amount);
                        }
                        if (m_manager != null)
                        {
                            m_manager.DestroyGO(this.transform.name);
                        }
                    }
                }
            }
        }
    This line
    EventHandler line [ OnPickUp(t_amount); one ]
        public static void PickUpEvent(float t_amount)
        {
            if (OnPickUp != null)
                OnPickUp(t_amount);
        }
    DamageManager line
        void OnPickUp(float amount)
        {
            if (photonView.isMine)
            {
                float newHealth = health + amount;
                health = newHealth;
                if (health > maxHealth)
                {
                    health = maxHealth;
                }
                photonView.RPC("PickUpHealth", PhotonTargets.OthersBuffered, newHealth);
    
            }
        }
    if (photonView.isMine) ^ one

    I think it might be because of scene clearing?? because it works when player first joins room and after when he rejoins exact level it gives that error :expressionless: