Creating the Seek-Health (or flee) state

The Seek-Health state occurs when the enemy runs low on health and can restore it by collecting a medikit. This state is unlike most others, in that, it can be reached or entered from any state. The entering of this state doesn't depend on its relationship to others, but only on the player's health. Specifically, this state should be entered when the enemy's health is reduced beyond a minimum floor. As a result of this configuration, be sure to hook up the Seek-Health animation state in the Mecanim graph to the Any State node that allows the run animation to be triggered in any state, as shown here:

Creating the Seek-Health (or flee) state

The Seek-Health ...

Get Mastering Unity Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.