Navigation

  • Recent
  • Tags
  • Users
  • Search
  • Login
Colyseus
  • Login
  • Search
  • Recent
  • Tags
  • Users

Documentation GitHub

We're migrating to GitHub Discussions. This forum does not accept new registrations since April 6, 2023.
  1. Home
  2. plyoung
plyoung

plyoung

@plyoung

Chat Follow Unfollow
4
Reputation
12
Posts
2.5k
Profile views
0
Followers
0
Following
Joined 6 Jun 2018, 14:06 Last Online 12 Jul 2018, 09:49
Location South Africa

  • Profile
  • More
    • Continue chat with plyoung
    • Flag Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups
plyoung Follow

Posts made by plyoung

Need advice on actions before joining a room

I want to allow a player to create an account and login. The player will be able to unlock character classes and I want to make these available before the payer enters a room (battle).

Is there a way to achieve this before a room is made or should I just make a "lobby room" to handle this? Any tips on transferring data from the lobby room to the "battle" room? For example the chosen character class and what characters a player is allowed to choose from?

I've also not decided on any database tech yet so any advice here would be welcome.

posted in Questions & Help • 22 Jun 2018, 08:48
RE: EntityMap iterator

oh, I see.. Use "in" rather than "of".
It looks much better now. Thanks.

posted in Questions & Help • 19 Jun 2018, 12:55
RE: How to create list rooms

I have no idea if we do not have access to "getAvailableRooms". If we did then you could simply have the client make that call every few seconds or minutes to get a fresh list.

posted in Questions & Help • 19 Jun 2018, 08:08
RE: EntityMap iterator

I know how to add players to the entity map. I am trying to find a better way to loop pver them without adding more variables. I was hoping the EntityMap had an iterator I did not know about.

Atm I must iterate over the list of clients to get an Id I can use to get a reference to a player object so I can call the update() function on that player object. This feels like a lot of work that could be made simpler.

Btw, I do not understanding your code. To me it looks like it would error out. The loop does not make use of "sessionId" at all and is calling update() on the players object which is of EntiyMap type.

posted in Questions & Help • 19 Jun 2018, 08:04
EntityMap iterator

Is there a better way to do this? I want to call update on all player objects in this.

players: EntityMap<Player> = {};

..
..

for (let client of this.clients)
{
    this.state.players[client.sessionId].update(dt);
}
posted in Questions & Help • 17 Jun 2018, 11:23
RE: [How] Auto leave room

Check the docs, http://colyseus.io/docs/api-room/#disconnect

As for tracking who created it you could simply keep a variable in the room class which, if not set, you set it to the client.sessionId of the joining client in onJoin. Of course if your variable is already set you know that this is the 2nd joining player and should not use its session id.

posted in Questions & Help • 17 Jun 2018, 11:15
RE: How to create list rooms

I don't known why we must to pass roomName = "battle" as parameter to method client.GetAvailableRooms () . Why its not empty ?

That identifies what kind of room you want to information about since you can have more than one type of room on the server. You might have "chat" room, or "battle" room, or "2vs2" room, "4vs4" room, "whatever" room, etc.

On server side you did something like this. See that 1st name "game" in my case, is a room name. You can have more than one of these statements in the server. gameServer.register("game", GameRoom);

client.getAvailableRooms() or setMetadata(...) anywhere ?

setMetadata is done on the server side, in your room class.

@endel I do not see getAvialabeRooms on client side API either. (Unity)All the room list related code is commented out in Client.cs

posted in Questions & Help • 17 Jun 2018, 11:09
RE: Timer

Check out http://colyseus.io/docs/api-timing-events/
You could set up a callback when it becomes the player's turn. They return a "Delayed" object which you can "cancel" if the player did perform his action in time.

posted in Questions & Help • 11 Jun 2018, 12:45
RE: Timing of movement

Ah yes, that would be much better. Thanks.

My first time trying to create a "real time" multiplayer game. I've only done turn-based, in multiplayer games, before so I'm not quite sure about all the correct ways to approach this.

posted in Questions & Help • 9 Jun 2018, 08:23
Timing of movement

Can anyone give me some advice on technical design around accepting and processing player input? I am using Unity for the client side.

Atm I am just sending a message to the server every frame as long as a key is held down and I am just adding a value to x/y when the command arrives. Would it be better to have a short timeout between sending such messages?

private void Update()
{
	if (Input.GetKey(KeyCode.LeftArrow))
	{
		client.Send(Msg_MoveLeft);
	}

...

movePlayer(client: Client, action: string)
{
    if (action === "L") 
    {
        this.players[client.sessionId].x -= 0.1;
    } 

How would one deal with movement speed server side? I was thinking I should collect the player's wanted actions like, move left, right, etc; and then in the "update" function, which is a setSimulationInterval callback, I would do the actual movement so that it is locked to some time interval (movement speed).

posted in Questions & Help • 8 Jun 2018, 15:47

© 2023 Endel Dreyer