Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

null reference callback " " for new input system

Discussion in 'Input System' started by ewanchurchill, Mar 30, 2020.

  1. ewanchurchill

    ewanchurchill

    Joined:
    Oct 10, 2018
    Posts:
    20
    I have started moving to the new input system however when trying to use my action key 'e' to use the PickUp() function it throws me the attached errors.

    I have set it up in the same way I have set up opening the menu and that works as expected so I cant understand why the pickup doesn't work.

    Any help would be greatly appreciated, thanks in advance,
    Ewan.

    Unity1.JPG Unity2.JPG unity3.JPG
     
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,381
    There's a NullReferenceException in your code at line 128. The original exception is mentioned in the next message after the error message. Bit confusing.
     
  3. ewanchurchill

    ewanchurchill

    Joined:
    Oct 10, 2018
    Posts:
    20
    Not sure if this helps but I moved the PickUp() into the Menu() as I know that works but i get the same errors just with the 'tab' key as that's my menu button.

    unity4.JPG Unity5.JPG
     
  4. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,381
    PickupItem.instance is null.
     
  5. ewanchurchill

    ewanchurchill

    Joined:
    Oct 10, 2018
    Posts:
    20
    Ah... using instance = this; in my pickupItem script solves the issues but isn't a great solution as it stops me picking up any other items after the first. Is there an alternative to 'public static instance'?

    EDIT: Nevermind I fixed the multiple instances issue. thank you for your help
     
    Last edited: Mar 30, 2020
unityunity