Declaring local variables in states causes problems

I have noticed for a long time that if I ever declare a local var with a state of the bot controller class, it will cause the game to crash when loading a new map from a map that contains this bot.

This is an example:

state MyTestState
    local int testInt;

So when adding this code to any AI controller, if a level is loaded that contains this bot (it will load fine), but if you then load a new map the game will crash. This indicates that it isn’t able to successfully destroy the actor when these state vars are declared.

Does anyone know a way around this. I’ve been getting around it by declaring class variables for use in states, but it would be much nicer to be able to declare local vars.

I found that if you declare them in the function or functions in the state you do not seem to have an issue, but if we defined them in the state itself and not in the function in the state it would crash on us also.

As far as I know, local variables are only for use inside functions. No special variables that exist only within a state. I think your approach using class variables is the only way to do what you want to do.

It’s strange that the compiler allows it though (and it works fine apart from when unloading the world).

i noticed that to.