Usage: gms_instance_sync ( id, flags, "var1", "var2"... )


Syncs the given instance. id is the instance_id (built-in variable: id).

The second argument is used to specify how the instance should be synced.

is_onetime: Instance will be synced once. Use this for instances with a predictable movement and a predictable destroy, for example: bullets.

is_extended: Instance will be synced at create and at destroy. Use this for instances with an unpredictable destroy, but a predictable movement. For example: remote-detonating bombs.

is_full: The instance will be fully synced. Use this for instances with an unpredictable movement and an unpredictable destroy. For example: AI controlled NPCs.

You can add the flag 'isc_local', to only sync the instance when other players can see it. (Syntax: 'is_extended | isc_local')

The given variables "var1", "var2", etc and the x, y, speed and direction will be sent.


//For the sake of this example, assume the bullet has a variable damage, and it should be synced as well.
i = instance_create(x, y, obj_bullet)
i.damage = 50;
gms_instance_sync(i, is_extended, "damage")

Replies (30)

Last message on 13 Jan 2018

bruno_chachi on 24 Dec 2017, 18:57:49
is_full works on game maker 8.0?
Size43 (Administrator) on 24 Dec 2017, 19:45:20
Yes, it works.
bruno_chachi on 25 Dec 2017, 17:12:32
I have an error only whit is_full

action number 1
of Begin Step Event
for object __newobject42:

In extension function gms_step:
Error in code at line 641:
_distance = point_distance(__iself_last_x, __iself_last_y, x, y)
at position 57: Unknown variable __iself_last_x
Size43 (Administrator) on 26 Dec 2017, 12:18:32
What does your syncing code look like?
bruno_chachi on 29 Dec 2017, 17:51:37
This in text file

// block
var i;
draw_text(view_xview,view_yview,"Haz click para crear bloques#Pulsa x para terminar");
bruno_chachi on 29 Dec 2017, 17:52:05
And the game executes the file
Size43 (Administrator) on 3 Jan 2018, 11:41:19
Are you also adding obj_piso using object_add?

The variabes __iself_last_x, __iself_last_y are set when you call gms_instance_sync, so I'm not quite sure how you're even seeing that error.
bruno_chachi on 5 Jan 2018, 17:56:58
obj_piso is in the game
Size43 (Administrator) on 7 Jan 2018, 15:51:07
When exactly do you get the error? Directly after creating the instance, or only after a while?

Are you using instance_deactivate anywhere?
bruno_chachi on 10 Jan 2018, 17:47:34
I don´t use instance_desactive.

The obj_piso creates, and then show the error
Size43 (Administrator) on 11 Jan 2018, 18:40:31
Would you mind mailing me your project (or a similar file that I can use to reproduce the error) at
bruno_chachi on 13 Jan 2018, 11:00:46
Okay :)
Dublann on 29 Mar 2017, 21:48:59
Hi size,

Im having the gms_instance_sync(id, is_full) in the create event of enemies and some other objects, but when playing, they appear duplicated. Why is it happening?

Also, when 2 players are connected, one cant see the other but are having collisions. Also this error appears. How can I solve it?:

action number 1
of  Step Event0
for object GMS:
instance_exists argument 1 incorrect type (5) expecting a Number (YYGI32)
 at gml_Script_gms_step (line 256) -                     if instance_exists(__i)
stack frame is
gml_Script_gms_step (line 256)
called from - gml_Object_GMS_StepNormalEvent_1 (line 5) - gms_step()

Size43 (Administrator) on 16 Apr 2017, 16:20:48
Are you maybe creating & syncing the instance on each client? You should only have one client create the instance, otherwise each client will sync an additional instance.
Dublann on 23 Apr 2017, 13:40:05
Thx for the comment. The problem Im having is that the enemies are placed directly in the room, therefore I dont know how to manage it. I tried using in the create event:
if gms_self_ismaster()
if gms_instance_is_owner(id)
    if room=rm_play
    if room=room_level4

But it doesnt work
Size43 (Administrator) on 24 Apr 2017, 11:49:13
Remove the if gms_instance_is_owner(id) check. Instances won't have an owner until they have been synced.
Dublann on 24 Apr 2017, 19:44:10
Done, but it isnt show in the game of the other player. What should I add in step event/draw event? Im having:

Step event
if gms_self_ismaster()
    if distance_to_object(obj_player)<=1
    audio_play_sound(sound_goblin, 1, false);
    if distance_to_object(obj_murcielago)<=1
    if( x < 0 ) x += room_width;
    if( y < 0 ) y += room_height;
    if( x > room_width ) x -= room_width;
    if( y > room_height ) y -= room_height;   

Draw event
if gms_self_ismaster()
    if distance_to_object(obj_player)<=128 or distance_to_object(obj_other_player)<=128

I also tried changing the if gms_self_ismaster() by if gms_instance_id but nothing.
Size43 (Administrator) on 2 May 2017, 13:24:48
Are you drawing anything at all if gms_self_ismaster() returns false?
Dublann on 2 May 2017, 15:14:31

Should I remove the gms_self_ismaster? or add gms_instance_is_owner(id) in the step and draw event?
Size43 (Administrator) on 8 May 2017, 15:22:07
Well if you're not drawing anything when gms_self_ismaster returns false, you won't see the object at all. You should draw something when that's the case as well if you want to see it.
Dublann on 27 May 2017, 10:40:27
Hey Size, could you see the email I sent you?
Size43 (Administrator) on 27 May 2017, 16:20:52
Sent you a mail back :)
Dublann on 7 Jun 2017, 11:49:32
Another mail sent with a small example :)
Dublann on 1 Apr 2017, 19:41:24
Hi again!

I solved the problem of not seeing the other_player object, but now, due to obj_player and obj_other_player are solids and they are created in the same position, the are colliding with each other and I cant move. I tried to modify the obj_other_player ystart, but it is not affecting. How could I solve it?

Also, I have noticed that the objects with gms_instance_sync(id, is_full) are duplicated, triplicated, etc. And their movements are not syncornized, they move independently and each player see different movements of them. How could I solve it?

Dublann on 1 Apr 2017, 20:11:53
OK, I removed the solid option of the obj_other_player and now I can move them (I suppose I dont need it).

But still I am having the problems with the instances and the error that appears (see 2 messages above).

PS: is there any way to edit a post? I dont like to spam the forum :(
littlecoolpug on 17 May 2015, 01:45:21
OK so I'm trying to make a zombie game, and the zombies don't sync, (so the zombies spawn on both peoples screen but the zombies are only visible on that persons screen) I need to make it when the zombie spawns in the game it's shown on both screens so would I do this in the zombie's create event:
or what please help me thanks in advance!
littlecoolpug on 17 May 2015, 01:52:26
sorry would it be like this, not like I said before:
gms_instance_sync(self, is_full, "zombielife")
littlecoolpug on 17 May 2015, 16:22:10
hello? reply......
Size43 (Administrator) on 17 May 2015, 19:09:07
I don't get paid to do this, so I'm not available 24/7. :)

Use something like this:
gms_instance_sync_var_add("zombielife", zombielife)
gms_instance_sync(id, is_full)

self is just a value like -1, id is the actual id of the instance. Specifying variables as parameters is only supported in GM8, in GM:Studio you'll need to call gms_instance_sync_var_add before the gms_instance_sync call.
littlecoolpug on 17 May 2015, 19:37:08
oh ok, and as long as it's free I'm fine with you not being available 24/7 :) sorry about that!