-
-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When logging in, later players may not be able to see who is around them. #47
Comments
The earlier report was in error. |
Yeah my problem is like that too. But I tried sevral times and the characters, hided, appeared suddenly. I mean I have no idea what the problem is. plz let me know if you have any idea the software working right way... |
@gusdnvkfks @shoshoi import { Client, Room } from "colyseus.js";
// custom scene class
export class GameScene extends Phaser.Scene {
// (...)
client = new Client("ws://localhost:2567");
room: Room;
async create() {
console.log("Joining room...");
try {
this.room = await client.joinOrCreate("my_room");
console.log("Joined successfully!");
} catch (e) {
console.error(e);
}
}
// (...)
} export class GameScene extends Phaser.Scene {
// (...)
room: Room;
// we will assign each player visual representation here
// by their `sessionId`
playerEntities: {[sessionId: string]: any} = {};
// (...)
async create() {
// (...)
// listen for new players
this.room.state.players.onAdd((player, sessionId) => {
const entity = this.physics.add.image(player.x, player.y, 'ship_0001');
// keep a reference of it on `playerEntities`
this.playerEntities[sessionId] = entity;
});
// (...)
}
}
|
Yeah my problem is like that too with still latest version of Colyseus (0.15) @kevinshen56714 , do you have any ideas for fixing this one? Thank and so appreciate! |
As @hawkcookie described, if the server is responding to fast, the phaserEvents.emit(Event.PLAYER_JOINED) happens before our player register phaserEvents.on(Event.PLAYER_JOINED). What I did to fix is not elegant, but it works. If someone with more experience on web development can suggest a way to await the event. I fixed by delaying the "emit" like this: Network.ts
|
Hello, thanks for this useful software !
When logging in, later players may not be able to see who is around them. Still, the call can be made.
Sometimes this happens, sometimes it does not.
I am trying this on the same host, with the same browser, and multiple tabs open.
The text was updated successfully, but these errors were encountered: