How can I reset a room?

Hi!!

How can I reset a room? I mean, return all objects to their place of origin.

Original Post on Discord

by user 801298590676156416

There’s currently no “easy” / builtin way to delete all state in a networked room. You can send a special message to the backend with the guid and key of the state entry you want to delete. Let me look it up

So you can use this.context.connection.sendDeleteRemoteState(guid:string) with the guid of the object you want to delete the networked state for that component/object

so you could iterate over all SyncedTransforms and send that message. Would that help? Usually its easier tho to create a new room. What’s your usecase?

I’m looking into adding a message for deleting all state

Next version will have a easy call for this :slightly_smiling_face: this.context.connection.sendDeleteRemoteStateAll(); (you need to make sure you’ll update the networking package to 1.1.0-pre on glitch for it to work
image.png

If you do that now (update the glitch package) you can also just do this.context.connection.send("delete-all-state") in one of your scripts and the state should be emptied when you refresh

That being said: in case you didnt refer to the networked state but just the positioning of the objects in the room: you can iterate all SyncedTransform components in a script in awake, store their matrices and wait for the networking event RoomEvents.JoinedRoom (you do that by this.context.connection.beginListen(RoomEvent.JoinedRoom, _ => { ... })) and then reset all their matrices to the previous values

Hi, thanks for your response.

For an educational activity I am going to have 3 sessions of 40 groups in each one. It would be better for me to have a reset button in each room than to create rooms every time.

Sadly my programming skills are not good enough yet, so I will have to create the rooms.

Thank you very much for your answer.

by user 801298590676156416