Weapon issue

General support.
Post Reply
User avatar
pyatyorochka
Contributor
Contributor
Posts: 31
Joined: Sun Jun 13, 2021 4:55 am

NullReferenceException: Object reference not set to an instance of an object
bl_GunManager+<ChangeGun>d__54.MoveNext () (at Assets/MFPS/Scripts/Weapon/Main/bl_GunManager.cs:457)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <127e81e1cb3441cc97d26b1910daae77>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
bl_GunManager:ChangeCurrentWeaponTo(Int32) (at Assets/MFPS/Scripts/Weapon/Main/bl_GunManager.cs:445)
bl_GunManager:InputManagerControll() (at Assets/MFPS/Scripts/Weapon/Main/bl_GunManager.cs:710)
bl_GunManager:InputControl() (at Assets/MFPS/Scripts/Weapon/Main/bl_GunManager.cs:238)
bl_GunManager:OnUpdate() (at Assets/MFPS/Scripts/Weapon/Main/bl_GunManager.cs:192)
MFPS.Internal.bl_UpdateManager:Update() (at Assets/MFPS/Scripts/Internal/General/bl_UpdateManager.cs:184)

What to do?
User avatar
Lovatto
Admin
Admin
Posts: 1834
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Hi,

Show me the line 457 of your bl_GunManager.cs script.
How to find your Invoice Number: Here
How to find your Order Number: Here
User avatar
pyatyorochka
Contributor
Contributor
Posts: 31
Joined: Sun Jun 13, 2021 4:55 am

Hello!

457:

Code: Select all

float hideTime = PlayerEquip[IDfrom].DisableWeapon();

Full code:

Code: Select all

public IEnumerator ChangeGun(int IDfrom, GameObject t_next, int newID)
    {
        CanSwich = false;
        bl_UIReferences.Instance.PlayerUI.LoadoutUI.ChangeWeapon(newID);
        float hideTime = PlayerEquip[IDfrom].DisableWeapon();
        //instantly disable the current weapon and active the next weapon
        if (changeWeaponStyle == ChangeWeaponStyle.CounterStrike)
        {
            PlayerEquip[IDfrom].gameObject.SetActive(false);
        }
        else if (changeWeaponStyle == ChangeWeaponStyle.HideAndDraw)
        {
            HeadAnimator?.Play("SwichtGun", 0, 0);
            //wait a fixed delay before active the next weapon
            yield return new WaitForSeconds(SwichTime);
        }
        else if (changeWeaponStyle == ChangeWeaponStyle.HideCompletelyAndThenDraw)
        {
            HeadAnimator?.Play("SwichtGun", 0, 0);
            //wait until the current weapon hide animation complete before active the next weapon
            yield return new WaitForSeconds(hideTime);
        }
        foreach (bl_Gun guns in AllGuns)
        {
            if (guns.gameObject.activeSelf == true)
            {
                guns.gameObject.SetActive(false);
            }
        }
        TakeWeapon(PlayerEquip[newID], true);
        bl_EventHandler.ChangeWeaponEvent(PlayerEquip[newID].GunID);
    }
Post Reply