[SOLVED] Photon Multiplayer Very Laggy!

[SOLVED]

I’ve finished making a multiplayer FPS Prototype using PlayCanvas and I’ve been using Photon to host it. I used the PlayCanvas multiplayer with Photon tutorial (Real-time Multiplayer with Photon | PlayCanvas Developer Site). It works but it is very laggy or something because it only updates the player’s or other player’s position after the keys are not being pressed instead of while being pressed.

[SOLVED]

An editor link of your project will be helpful here.

https://playcanvas.com/project/1276292/overview/fps-game-finished-updating

It seems like you currently have it coded that way.

image

The pos variable of your statement is only a zero vector 3 when there is no input of the keys. When you press a key you create a vector 3 to move the player in a certain direction.

Maybe you can try the code below.

if (!pos.equals(new pc.Vec3(0, 0, 0))) {
    this.entity.translate(pos);

    const { x, y, z } = this.entity.getPosition();
    this.app.fire("loadbalancing:sendPlayerPosition", { x, y, z });
}
1 Like

Thank you very much. I am new to using Photon in PlayCanvas and the tutorial project didn’t need it the way I am using it.