why does untiy keep telling me in the ai script

8496554--1131005--upload_2022-10-7_17-32-31.png

Since the error happens at the line 34. anything could be null, for example any state, anything inside of your side or your statemachine itself.

would start to debug through

i dont under stand like i copy paste this from my old project on version 2021.3.3f1

this is the old one

they are the SAME

My guess is you had an error earlier on Start() that prevented stateMachine from being assigned to. The two possible reasons are:

  1. FindGameObjectWithTag on line 22 did not find an object with the “player” tag, returned null, then caused a null reference exception when trying to access the .transform of a null object.

  2. An exception was thrown in the AiStateMachine constructor.

FYI, when an exception is thrown, the currently executing function aborts execution right there: the lines after that point will not execute.

Tysm for telling me that you are a life saver