Global variable set to NaN?

0 favourites
  • 6 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi guys,

    My layout starts and creates a bunch of global variables. The last of which is instead of setting to 0 is being set to NaN.

    Anybody know what this is and how to stop it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • ...and before you ask the only time the value is set is when it is created i.e. Global number variable1 = 0

  • NaN means Not a Number. You will want to make sure the 0 is not "0". If it's wrapped in quotes, Construct would try to store a text value, not a number value. Hence the NaN result.

    If that is not the case, I would have to look at your capx to help further.

  • I found your previous topic and downloaded your file. When I run it, I see both layouts counting up at the same rate. Starting on layout 1, the text begins counting, when I swapped to 2 it takes up the count right where I left off. I don't see the NaN result. I ran it in Chrome, FF and IE11. It ran fine in all 3. What browser are you using?

  • I understand you get a NaN when setting a string to a number. However, I am not doing that. The only time the value is set is when the global is declared with a default value of 0. What is interesting is the second time I run the layout, i.e. title screen to game back to title screen, It is no longer a NaN and set to 0.

    The capx was something I created instead of providing my whole project. It wasn't the problem I thought it was and that capx proved it. After debugging I found that the last global variable in my layout was returning a NaN. On the second time the layout ran it returned 0.

  • I made a new variable called GlobalFullVersion and used that instead. It must not like the variable name GlobalUnlocked.

    Very strange

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)