I was trying First-Person with multiplayer using photon but there I can’t see any type of rotation for other players joining I tried updating the rotation of the player in the player.js script too here is my code and project link PlayCanvas | HTML5 Game Engine. Any support is appreciated. I am very new in this thing trying new stuff:slightly_smiling_face:.
var Player = pc.createScript('player');
Player.prototype.initialize = function () {
if (!this.app.loadBalancing || !this.app.loadBalancing.isJoinedToRoom()) {
console.error("not connected");
}
this.tmpVec = this.entity.getPosition().clone();
this.tmpVec1 = this.entity.getRotation().clone();
this.app.on("loadbalancing:raiseEvent", this.raiseEvent, this);
};
Player.prototype.postUpdate = function () {
const playerPos = this.entity.getPosition();
const playerRot = this.entity.getRotation();
if (!this.tmpVec.equals(playerPos)) {
this.tmpVec = playerPos.clone();
this.raiseEvent();
}
if (!this.tmpVec1.equals(playerRot)) {
this.tmpVec1 = playerRot.clone();
this.raiseEventI();
}
};
Player.prototype.raiseEvent = function () {
if (!this.tmpVec.x || !this.tmpVec.y || !this.tmpVec.z) return;
const data = {
position: {
x: this.tmpVec.x,
y: this.tmpVec.y,
z: this.tmpVec.z,
}
};
console.log("raiseEvent!!");
this.app.loadBalancing.raiseEvent(0, data);
};
Player.prototype.raiseEventI = function () {
if (!this.tmpVec1.x || !this.tmpVec1.y || !this.tmpVec1.z) return;
const data1 = {
rotation: {
x: this.tmpVec1.x,
y: this.tmpVec1.y,
z: this.tmpVec1.z,
}
};
console.log("raiseEventI!!");
this.app.loadBalancing.raiseEventI(0, data1);
};