Time for action – Subclassing the Seeking state
We'll use an extension of the Seeking
state to make our enemy move faster.
First, delete the
auto
keyword from ourSeeking
state. We'll make our new state theauto
state.Now let's create our new state and call it
FastSeeking
:auto state FastSeeking extends Seeking { }
Don't let the name throw you, the new state's name doesn't have to contain the old state's name or be related to it at all, we could call it Fiddlesticks if we wanted to.
Be sure to place this state AFTER the Seeking
state, otherwise the compiler will give you an error telling you that it cannot find the state we're extending from.
Now let's create a
BeginState
function inside our new state and change it slightly from the regularSeeking
state's version:function BeginState(Name PreviousStateName) { MovementSpeed = default.MovementSpeed * 2.0; if(!bAttacking) MyMesh.SetMaterial(0, SeekingMat); }
We're using default.MovementSpeed
here instead of just MovementSpeed
, otherwise...