Hi all,
I am unsure why this is happening, but the “this.” variables I declared in initialize cannot be accessed by my function in the same script(point-and-click.js).
Project file: https://playcanvas.com/editor/scene/1373263
Here is my initialize:
however, it doesn’t carry through to a function written in the same script. Here is a screenshot from chrome’s debug tools:
I checked another project that does the same thing and saw this:
This unfortunately leads to a “reading” error since the variables don’t get passed. As a workaround, I redeclare the variables in the function (see screenshot below) just to get it to work, which I think only allows the other model to look at the player-controlled model (w,a,s,d) as opposed to walking towards it.
I read through the forums*(Variables declared in initialize function return errors later saying they are not defined)* and found how .this variables should be carried over to update, which I assume should also be carried to any functions within the script.
Is there a reason why this is happening? I am not sure if this is a bug or a feature that I need to consider when working on projects.
Any help will be greatly appreciated. Thanks!