if (this.players[data.id].entity.children[1].name !== data.av && 'Stock') {
avatarurl = this.players[data.id].entity.children[1].name = data.av;
console.log('Naujas modelis detected');
console.log(avatarurl);
players = this.players[data.id];
this.app.assets.loadFromUrlAndFilename(avatarurl, null, "container", function (err, asset) {
avatarentity = new pc.Entity('avatarModel');
// Add the loaded scene to the hierarchy
avatarentity.addComponent('model', {
asset: asset.resource.model
});
console.log('loaded');
players.entity.children[0].model.asset = avatarentity.model.asset;
console.log(players); //It logs all players with same player ID, why?
if (asset.resource.animations.length > 0) {
avatarentity.addComponent('animation', {
assets: asset.resource.animations
});
}
});
console.log(players); //It logs all players with their IDS
}}
};
This script gets model url from server data, downloads and setts it for other player
The problem: I’m testing it using 3 game instances, 2 players have models loaded (non stock, we exclude stock modeled players and leave them as it is), when the 3rd instance joins, it only sets model for one player, not for both, until I change it again, should I loop or…?
each player hasdata:av
it has url of model which is setted when player selects model/avatar, stock means player uses stock model