Instance synchronization workaround

Posted by PainiteOfficial
Hey Size! (Or whoever is reading this)
Recently I've been working on a game using gm server and it works great! except the sync part.
The game is a rhythm bullethell so I have to synchronize the bullets so that each player can dodge.

The big problem is that the game also has powers. For example, if a player uses the "slowmotion" ability,
all the bullets slow down, making dodging them easier. To sync the bullets at all the players i have to use the
"is_full| isc_local" method because the slow motion wont work on the other players otherwise (one player sees
the bullets slowed down while the other ones see them at full speed if I use is_extended) But because the limit for full sync is 100 instances (or 500 if you upgrade) i always get a error stating that i passed that limit.

Is there a solution to this problem? Can I somehow make this ability work and not crash the game using the is_extended method or something of that matter?

Thanks!

(tl:dr: i just need a way to sync the speed of an instance without using is_full method)

Replies (5)

Last message on 28 Sep 2020

Size43 (Administrator) on 28 Sep 2020, 15:37:48
Using full instance sync is very expensive, since that always syncs the instance's position. Updating positions for thousands of instances on the screen at the same time is likely going to lag.

Are all bullets slowed at the same time? If so, you could use a single global variable (gms_global_set and gms_global_get) to synchronize the bullet speed and then apply that speed effect on each client locally.
PainiteOfficial (Topicstarter) on 28 Sep 2020, 16:01:10
that's what im using (global.slowmotion) but unless i use full sync other players don't have the same effect. :/
Size43 (Administrator) on 28 Sep 2020, 16:07:53
In order to sync the global variable, you'll need to call the corresponding GameMaker Server functions, i.e.:

gms_global_set("slowmotion", global.slowmotion)


and

global.slowmotion = gms_global_get("slowmotion")


Make sure to only call gms_global_set when you are changing the value, otherwise you'll get two clients fighting over which value it should be.
PainiteOfficial (Topicstarter) on 28 Sep 2020, 16:16:14
thanks! onther thing i want to ask about global variables is that, you need to put a gms_global_get("slowmotion") function in the other player's step event right? To make sure everybody gets the variables. Or am I doing something wrong :D
Size43 (Administrator) on 28 Sep 2020, 19:03:05
Exactly! You need a gms_global_get to read the value back in to the global variable.