Build not working on the course build a 3rd person combat and traveral rpg game

on the build i get errors


from the Ai saying “Object reference not set to an instance of an object”…

You should be able to click on the error message itself and get to a stack trace, just like in the Console.

ok


i will upload the text file with all the errors

Ok, so the NREs are occuring in the EnemyBaseState.cs on line 27, in the IsInChaseRange() method, which is being called from EnemyIdleState()…

Let’s take a look at your EnemyBaseState.cs. Be sure to mark line 27 where the error is occuring, and we’ll narrow down what’s showing up as null.

Here is the whole EnemyBaseState (with


line 27 highlighted).

For some reason, Player is null… To prevent the error (and subsequent freeze), null check Player at the beginning of IsInChaseRange()…
That being said, it shouldn’t be null… How is EnemyStateMachine getting it’s reference to the Player?

Ok I will check that later as I’m going to school at the moment.

Here is the way i access the player gameobject.

Hmmm… if Player was null in the first line of start, then SwitchState() would never get a chance to fire…
(NRE’s tend to kill methods)
But somehow, it’s not staying set by the time you get to the IdleState().Tick…
All the same, let’s Debug it to be sure…
Add this after the Player= …;

if(!Player)
{
    Debug.LogError($"{name} was not able to locate the player");
}

Unfortunately, I’m going to be out of town over the weekend, but we’ll get back to this as soon as I return.

Privacy & Terms