Forum rules - please read before posting.

Scripting set variable not working properly?

Hi
I have a simple code where essentially there's an enemy, it dies, and decreases the variable for how many enemies are left.

But in game, when I kill 1 enemy, AC sets the variable to -1 instead of decreasing it by 1.
Here:
imageDoes anyone know what I could be doing wrong?
Thank you :)

Comments

  • Please use code-sharing websites such as pasteall.org instead of screenshots - it makes it much easier to debug.

    The EnemyCount variable can't be syncronised to AC's Local Variable in its declaration.  Remove it, and instead use something like this:

    public int enemyCount = AC.LocalVariables.GetIntegerValue (0);
    enemyCount --;
    AC.LocalVariables.SetIntegerValue (0, enemyCount);
  • Hi Chris
    Thank you
    I'm probably being pretty thick right now but I've changed it to how you shown and it's still setting the variable to -2
    http://pasteall.org/993255
  • You didn't change it to how I showed.  Barring the (mistaken) "public", those three lines need to be placed together:


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.