Out of scope error

so i am trying to do ai for the game im working on but in the code it says, states use out of scope, here is the code - Chase.prototype.setAnimation = function (state) {
if (this.state !== state)
var states = Chase.states;

    this.state = state;
    // Set the current animation, taking 0.2 seconds to blend from
    // the current animation state to the start of the target animation.
 this.entity.animation.play(states[state].animation, animation=0.2);

Hi @00ferman2!

As you have not attached your entire code, this answer may be a little generic, but should give you an idea of what the error means. Usually, an out of scope error means that you’ve used the variable outside the local scope in which you’ve declared it. This article from W3 schools should help you understand scope a bit better. Hope this helps!

1 Like

If you want to add your code please do that with the Code Highlight and place all the code between the signs.


1 Like