Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question NullReferenceException error

Discussion in 'Testing & Automation' started by Unitkiv, Apr 7, 2023.

  1. Unitkiv

    Unitkiv

    Joined:
    Jun 14, 2022
    Posts:
    78
    Hi there,

    Today I tried to run my project. However Unity warns me with this message: “
    NullReferenceException: Object reference not set to an instance of an object
    LookAtFollowDz.MoveToBall () (at Assets/LookAtFollowDz.cs:76)”

    I got panic because my project has been working up to this day and everything seems correct in my code.

    I would be thankful if you got any idea of why this error is happening.
     
    Last edited: Apr 7, 2023
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @Unitkiv please seach for how to fix a null reference error. This is the most basic thing you need to learn to fix first. There is almost an endless supply of posts about this topic on this forum. If you say your project was working earlier, it is likely that you have lost a reference to some object in some of your components, and that causes the code to say it can't find something. So check the Inspector and all your object which have components you have created/used and see if any of the variable fields are empty.
     
    Unitkiv likes this.