Why do we need to calculate timeSinceLastSawPlayer every frame?

Same places the variable timeSinceLastSawPlayer just outside of the if else if chain inside of Update(). This means for every enemy on every frame we are calculating this variable.

Instead I have this calcuation (timeSinceLastSawPlayer += Time.deltatime;) inside of the else if statement with SuspicionBehaviour(). The only time the AI will move onto guard behaviour is when timeSinceLastSawPlayer is > suspicionTime and therefore will stay higher until they see the player again. I think this is much more efficient and I am not sure why Sam calculates it every frame.

1 Like

That does look like it would work, yes.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.