#im getting an error which state that it

1 messages · Page 1 of 1 (latest)

quiet wave
#

any help would be appreciated

stiff oak
#

you cut off the liune numbers in your screenshots :((

#

the saddest of sadnesses

#

!code paste sites are better for sharing code

simple deltaBOT
stiff oak
#

anyway it seems like the stateMachine variable is null

#

which means you didn't properly initialize it.

stiff oak
#

thankn you

#

so yeah again

#

it seems like the stateMachine variable is null
which means you didn't properly initialize it.

#

you'd have to assign stateMachine somewhere to a valid reference to your state machine

#

Showing the baseState code would be useful

#

and wherever you create or initialize these states

quiet wave
#

they're assigned in the base state script

#

or do i still need to do it for each script?

#

the basestate script

stiff oak
#

it merely declares the variable

#

you would have to actually assign it to something

#

public StateMachine stateMachine; < this is just a declaration of a variable

#

to assign it to something you need to do stateMachine = something; somewhere

#

presumably this should be done at the point when you create the state

#

In such cases it's usually best if you use a constructor to ensure the machine is always set when creating the state.

stiff oak
#

You would need to do something like:

        patrolstate = new PatrolState();
        patrolState.stateMachine = this;
#

but it would be better if you made a constructor

#

then you could do cs patrolState = new PatrolState(this);