My Unity 3D project is acting weird since I left

I’m using Unity 2023.2.5f1. I left my two projects working perfectly and I gave a interval for working on another project for about a month. When I open two of my projects Unity doesn’t seem to recognize my projects. For example, the players doesn’t get animated until other player slide to tackle them (CharacterController.Move called on inactive controller). Another example is when player shoots the ball onto goalie it gives NullReferenceException: Object reference not set to an instance of an object.

I didn’t encounter these errors on my project before. I can’t help keep asking to myself what has changed now :unamused_face:?

To that end, we use source control. :wink:

Normally project doesn’t “rot” like this. On the other hand, code rot is a thing.

If there were absolutely no internal (in editor, or editor version) or external (virus scans, zip & unzip, cleaning tools, OS) changes then the project should work and behave as before. First thing I’d try is to delete the Library folder and try again.

You’re also using a very, very early LTS version “5f1” which by definition have more issues than later patch releases. For 2023.2 that was 21f1 although you could just as well upgrade all the way to Unity 6.0.45f1. This is for after you got the project working in the first place.

That is not debugging.

You have a boring old plain “whatever” bug.

HOW it got there is irrelevant. Maybe it was there all the time and something luckily kept you from hitting it, such as timing or scripting order.

Go fix the bug.

In this case, it’s easy because…

The answer is always the same… ALWAYS!

How to fix a NullReferenceException error

Three steps to success:

  • Identify what is null ← any other action taken before this step is WASTED TIME
  • Identify why it is null
  • Fix that

NullReference is the single most common error while programming. Fixing it is always the same.

Some notes on how to fix a NullReferenceException error in Unity3D:

And generally, here is how to debug:

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

Remember with Unity the code is only a tiny fraction of the problem space. Everything asset- and scene- wise must also be set up correctly to match the associated code and its assumptions.

Looks like Unity got a bit moody after the break :sweat_smile:. This kind of issue usually happens when cached data gets outdated or references break silently. First, try Reimport All Assets from the Assets menu. Then, close Unity and delete the Library folder, Unity will rebuild it cleanly. Also, double-check all inspector references like Animator, Ball scripts, etc., to avoid that Null Reference Exception. The Character Controller. Move error suggests the controller might be disabled or inactive, ensure it’s active when called. Confirm your API compatibility level and scripting backend in Project Settings. By the way, if you’re into student tools, I recently came across a handy CGPA calculator, really helpful for tracking grades while juggling projects like this!

Thanks :slightly_smiling_face:,

I installed Unity 6 6000.0.45f1. Nothing has happened. But at least my project runs with bugs (I eliminated the bugs by using the code editor but I found that it’s a temporally solution). My project has got the same symptoms hashir780 mentioned. So I deleted the files in the Library folder. The project got broken (thanks god I found the files in the Trash so I restored the files back). I deleted the files in the Library folder of the unity project. Recently I tried to Reimport All Assets from the Assets menu then I closed Unity and I even deleted the Library folder. Still, the project got broken.

Now, on my backup project I will Reimport All Assets and when Unity opens automatically I’ll try to run the project.

My project starts at run-time. I also re-installed the components (Player Movement X, Falldown etc…) in the Inspector. Still it gives some errors like the “Null Reference Exception: Object reference not set of an instance of an object. PlayerMovementX.Sliding () (At Assets/PlayerMovementX.cs:241)” error when player slides onto computer (rival player) to get the ball while the rival player slides to get the ball from the player it won’t give this error. The relevant script is like this on both computer and player:

                 void Sliding()
                 {
                         if (slidingTime <= maxSliding)
                        {
                                   slidingTime += Time.deltaTime;
                                  animator.SetTrigger("Tackle");

                                 Collider[] rivalHit = Physics.OverlapSphere(attackPoint.position, attackRange, rivalHits);

                                foreach (Collider rival in rivalHit)
                               {
241                                   rival.GetComponent<FallDownrival>().TakeDamage(Damage);
                               }
                      }
               }

I have Player’s Shoot script too. Should it be better if I put this Sliding() method in to Shoot script.