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

arturspon

@arturspon

Chat Follow Unfollow
0
Reputation
6
Posts
1.3k
Profile views
0
Followers
1
Following
Joined 12 Jan 2021, 01:10 Last Online 10 Sept 2022, 00:17

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

Posts made by arturspon

RE: State not updating in nested object

@endel Hi again,

Just to give an update, the good news is that I'm not having issues anymore with state updates after using new instances everywhere.

But I still can't figure out why I'm getting errors when using the .clone function. I'm getting a null error, but my object is not null.

Anyway, I'm glad that I can make it work with the .assign() workaround for now.

Thanks!

posted in Questions & Help • 2 Jun 2022, 12:42
RE: State not updating in nested object

Hi @endel,

I'm not sure what do you mean by re-using schemas. What I have is multiple service classes to break up my code and separate pieces of logic. These services take the room and schema instance in their constructors, maybe this could be the cause of the issue?

Furthermore, I tried to use the .clone(), but I'm facing an exception when doing so. After a little bit of research I came across this issue on Github (https://github.com/colyseus/schema/issues/81). Then I removed all my constructors, but the exception still persisted, like the following:

0_1653137962249_Screenshot_2.png

For now, I'm using this workaround:
Instead of doing spot.playerCard = spot.playerCard.clone()
I do this: spot.playerCard = new PlayerCard().assign(spot.playerCard)

Thank you for your response! (and nice to see that you're brazilian, amazing job on Colyseus!!!)

posted in Questions & Help • 21 May 2022, 13:04
State not updating in nested object

I'm making a card game and trying to make a modification on a card.
My schema struct is somewhat like that:

field -> rows -> spots -> playerCard

My problem is, when I try to modify the object, the schema don't update, but when I move my card in the field for example, the values that I applied to the card finally appears.

I'm modifying the state like that:
this.state.field.rows[rowIndex].spots[spotIndex].playerCard.modifiers.push(playerCardModifier)

One workaround that I've been using is creating and entire new spot object (parent of my playerCard) and assiging it, this way the schema is properly updated.

The workaround is like this:
const tempSpot = new FieldSpot(spot.index, spot.ownerType)
tempSpot.playerCard = spot.playerCard
this.state.field.rows[rowIndex].spots[spotIndex] = tempSpot

Is there a way to make the state update without creating a new object?
I tried cloning the object with javascript spread operator, but that don't work for schemas, since spread just copy the enumerated values of an object.

Thanks in advance.

posted in Questions & Help • 7 May 2022, 13:03
RE: TriggerAllFillChanges InvalidCastException

Can't make it work... Well, for now I will be using a server side "hack" to trigger the state change at the start of a match.
Oh, and I also add this to the Schema.cs file to the error go away:
0_1610493539520_tostringcast.png

posted in Questions & Help • 12 Jan 2021, 23:17
RE: TriggerAllFillChanges InvalidCastException

I am still investigating the issue. It seems that I cannot change scenes after connected to a room, if I change the TriggerAll() throws the error.

Does anyone have any ideas?

posted in Questions & Help • 12 Jan 2021, 22:28
TriggerAllFillChanges InvalidCastException

Hi,

I have a class with my Client and Room variables in Unity.
I was using just one Scene in Unity, and the game was working fine.
When the game starts, I am using ColyseusManager.room.State.TriggerAll(); to receive the changes from the server.

But then I decided to make two scenes for better organization of my game:

  • The Scene 1 have a button to the game leader send a command to the server to start the game.
  • The Scene 2 is the game itself.
    Both of these scenes use the static variables (room and client) from my singleton class.

The problem is that, after starting another scene, the method TriggerAll() throws this exception:
0_1610414513285_colyseus_er.png

Thanks for any help!

posted in Questions & Help • 12 Jan 2021, 01:20

© 2023 Endel Dreyer