Hello again. I am trying to add a script component (and a script) programmatically.
I use self.Players[playersData.ID].addComponent("script"); to add a script component. Then I add the desired script using: self.Players[playersData.ID].script.create("player");
I changed the code since then…also commented the code that gives me the issue while experimenting with it. Check again now. The line of code that is creating the issue is line 24 from Scripts/network.js
var Player = pc.createScript('player');
// initialize code called once per entity
Player.prototype.initialize = function() {
this.entity.model.meshInstances[0].material.setParameter('material_diffuse', new pc.Color(0, 1, 0, 1));
console.log("Worked!");
};
// update code called every frame
Player.prototype.update = function(dt) {
};
Why are you setting a material’s diffuse color like that?
Change it to:
var Player = pc.createScript('player');
// initialize code called once per entity
Player.prototype.initialize = function() {
var material = this.entity.model.meshInstances[0].material;
material.diffuse.set(0, 1, 0);
material.update();
console.log("Worked!");
};
// update code called every frame
Player.prototype.update = function(dt) {
};