I cannot work and access any attributes in one method, however, I can call other methods through this.
Even the console.log() raises this error. Attributes can be accessed normally in other methods.
UpdateHealthEntity causes the error as well as the method it gets called in. However, everything works perfectly in lerp players.
Could it be that I am calling this method before the attributes are initialized?
Here is the link to the project PlayCanvas 3D HTML5 Game Engine
The issue is in client.js
I parsed and tried again - same result. I found that the error occurs in the manageServerData function. Putting any of the attributes inside produces the same error. They work completely normal in other methods.
I can call other methods from this method but cannot do attributes. I cannot even try to check if undefined - it provides this error.
Player is a reference to entity here, I have parse the script.
I call the method every time the socket receives the frame call. I suspect maybe its due to the fact that it gets called somehow before the attributes are initialized. But I still have no clue tbh. This being said I can continue with the project but I still would be interested if someone can explain why this occurs.
Would it be possible to share the project to take a look? It sounds like you might have a scope issue where the this object isn’t the script instance on your object (Especially since you are working with Sockets), but without seeing the setup, I can’t say for sure.
Since you gave me write access on your fork, I went ahead and pasted my edits there, commenting out the original code so you can see what I did. It seemed to work when I tested my fork. If it works for you, I will delete the fork I made.