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. bobalazek
bobalazek

bobalazek

@bobalazek

Chat Follow Unfollow
0
Reputation
2
Posts
1.1k
Profile views
0
Followers
0
Following
Joined 27 Mar 2018, 13:42 Last Online 15 Apr 2018, 16:49

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

Posts made by bobalazek

RE: Listen to non-primitive variables

Ok, thank you. Oh yeah, I did actually figure it this way, but in this case, I'm worried about performance, as it would need to do 7x (10x, if I would also include the scale) more callback calls as if it would just return the array. So the string solution does work ok (.split('|')/.join('|')), but it sends/receives more bits of data.
Mean, for now, there is no way to hack around, so I would be able to get an array in "one batch"?

posted in Questions & Help • 27 Mar 2018, 16:21
Listen to non-primitive variables

Hey!

I have a question regarding the .listen method for coloseus.js client.

So, the thing is, that I send the current position & rotation to the server, which looks something like this:

serverRoom.send({
    action: 'entity:transform:update',
    detail: {
        id: mesh.id,
        transformMatrix: [
            meshTransform.position.x,
            meshTransform.position.y,
            meshTransform.position.z,
            meshTransform.rotation.x,
            meshTransform.rotation.y,
            meshTransform.rotation.z,
            meshTransform.rotation.w,
        ],
    },
});

my room's state looks something like this:

public onInit (options) {
    this.setState({
        entities: {}, // key_id: { id: 1, transformMatrix: [0,0,0,0,0,0,0] }
    });
}

Now, I want to listen for changes of other entities like that:

serverRoom.listen('entities/:id/transformMatrix', (change: DataChange) => {
// listen for changes
});

But that doesn't seem to work (it only fires for the first add operation & the remove operation; It doesn't ever fire the replace operation), if the transformMatrix variable is an array. My temporary workaround is, to set it to a string, and also send the transformMatrix as a string.

Is there a way I could get the array inside the serverRoom.listen() method?

posted in Questions & Help • 27 Mar 2018, 14:01

© 2023 Endel Dreyer