[SOLVED] Undefined attributes

I am almost sorry to ask this question, I am starting with PlayCanvas and I do not understand why my script attributes remain undefined when trying to access with this.{attribute}. Below the few lines I am trying to make working and comments with console.log results. Thanks for your help.

Hello @Ougogogadget ,

Indeed this is a weird issue… Is it possible to post a project link to take a look?

Is this link working ? PlayCanvas 3D HTML5 Game Engine

1 Like

Not sure why but the issue is that you’re using an arrow function on initialize instead of a normal function declaration. Try changing it like that should solve your issue:


Nice catch, indeed an arrow function used at that point will automatically use the this that is available at the time the function is evaluated. And that this won’t be the script instance but most likely the global window context.

In any case stick with regular functions when declaring your script prototype methods.


It works, thanks for your help !