Concatenate Scripts - some variables are null

when making a build with Concatenate Scripts turned on, my game does not work correctly, some variables are null , is that normal?

i have gotten nulls before when concatenating scripts, or maybe im just not good at this!
But it didn’t seem to effect my game really.

It shouldn’t do. Is this concatenate and minify or just concatenate?

If it is a public project, can you post a link. If private, can you DM me and add yaustar to the project please and I look at it as soon as I can tomorrow.

@vgupgrade I’ve forked the project, updated an asset id that was hardcoded in the source code and published the build.

It looks like answerClick as a name is used both for a variable in one file (dataG.js) and a function in another (actions.js).

The behaviour of what happens seems to be different in one large concatenated file and separate files due to hoisting:

Easiest solution is to have the function name or variable to be different or since answerClick as a function is only used in one place, make it a function as part of the AnswerClick script type.

To test without build/publishing, you can tick concatenate scripts in the launch button here:

There may be other issues like this as the project relies a lot on global data and functions. It may be worth reviewing what is in the global scope and perhaps look to scope variables and functions that don’t need to be in the global scope into anonymous functions.

1 Like

man! thank you very much for your attention.

I’m migrating from Unity C # to Playcanvas Js, I’m really enjoying the engine, we created educational games and they need to work in the browser and I found the playcanvas amazing.

\ o /


No problem, did this manage to resolve the issue you were having?

yes, all right men :-), wow how did you find this in this bunch of script, you’re a wizard lol

Great to hear!

Heh, in this case, I saw that answerClick was null and wondered if it was a variable referencing a function. A quick search all showed that the name was both used for a variable and a function. Not sure what JS actually does in that case but easy to avoid by using different names :grimacing: