on the build i get errors
from the Ai saying “Object reference not set to an instance of an object”…
on the build i get errors
You should be able to click on the error message itself and get to a stack trace, just like in the Console.
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.
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.
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.