I’ve been working on my net code it send and receives fine but the part of the code that actually changes the material gives an error saying ‘Uncaught TypeError: Cannot read property ‘model’ of null’ even though there is a model attached to my entity.
Here is a look at the actual code to give a more in depth look
Edit: I Redacted the link because it is no longer necessary.
Hi @WilliamBoersma31! Based on your error description you have to check
this.players[data.id].entity. The result of that part seems to be
null at that moment.
No a few lines above the script is able to fetch the rigidbody of the entity using this.players[data.id].entity.
(its on line 72 which is visible in the picture)
Please add the rule below right before line 80 and check the result in the console, just to be sure.
If the result is good then you can do the same with the rule below.
it said null. But how do I make it stop being null and actually correspond to an entity like it does on line 72?
Update: I noticed there was a missing semicolon in my server side code and fixed it. Now there are no errors but its still not changing the material
Great. Your rule looks correct so I think you have to check
this.DYLTEX. How do you define this material?
its defined on lines 2 - 5
Update Again: Turns Out I forget to get rid of the // in front of my this.players[data.id].entity.model.meshInstances.material = this.DYLTEX;
which made the error go away when i fixed it the error came back.
Yet Another Update: I fixed another error on the server side and now it says the add player code is broken specifically ‘this.players[data.id] = data;’ located on line 64
here is access to the server side code if it helps.
Edit: I redacted the link because it is no longer necessary.
It’s not the same data as you use on line 72 from the script above?
yes but the one on line 72 has no reference to a rigidbody also do you know why its messing with my add a player code?
New Error: playcanvas-stable.js:22578 Uncaught TypeError: meshInstance.material.updateShader is not a function
at ForwardRenderer.updateShader (playcanvas-stable.js:22578)
at ShadowRenderer.submitCasters (playcanvas-stable.js:21528)
at ShadowRenderer.render (playcanvas-stable.js:21569)
at ForwardRenderer.renderShadows (playcanvas-stable.js:22557)
at ForwardRenderer.renderComposition (playcanvas-stable.js:23447)
at Application.render (playcanvas-stable.js:69841)
the add player error seems to be a fluke but this one crashed the game outright
EDIT: The Add Player one is a fluke i’ve hit play about 20 times now its this error which is something about changing materials with in playcanvas stable
Unfortunately I haven’t delved into making a multiplayer game yet, so I can’t help you with the multiplayer part.
luckily i got the multplayer part all done just need to figure out this playcanvas stable error
I solved It!
the reason we were getting that playcanvas stable error was because we weren’t referencing a valid material to get the actual material we needed to add .resource on to our reference to DYLTEX.
To be honest, I wanted to say that before when I asked you how you defined the material, but at that point you said your old error was back. Anyway, glad you managed to do it yourself. Good job!