GameMaker programming instances after their creation

If I were to create numerous instances of an object (which has no programming), would I then be able to program that one object later on, thus effecting all of its instances with that programming...? I ask because the manual cautions that this may not always work.

Also: If I were to have an object in a room and then duplicate that room numerous times, would those duplicated rooms contain regular instances of that original object, or would those instances be something diferent somehow.

thx
 
H

Homunculus

Guest
If you add instances of an object to a room, and then later edit that object, all the changes are automatically reflected on the instances already placed in the rooms, so no worries (if that’s what you are asking about). I have no idea where or why the manual would say otherwise.

You are looking at things the wrong way though. Instances only exist at run time, and are based on the object (like a blueprint) as it is defined when running the game. When placing them in a room you are not actually creating instances, you are simply saying “when the game is run and the room entered, create some instances at these locations”.

This should also answer your second question as well.
 
If you add instances of an object to a room, and then later edit that object, all the changes are automatically reflected on the instances already placed in the rooms, so no worries (if that’s what you are asking about). I have no idea where or why the manual would say otherwise.

You are looking at things the wrong way though. Instances only exist at run time, and are based on the object (like a blueprint) as it is defined when running the game. When placing them in a room you are not actually creating instances, you are simply saying “when the game is run and the room entered, create some instances at these locations”.

This should also answer your second question as well.
Thanks for that. Here's that info that I was referring to:
There are also a number of functions that permit you set the properties for an object. It should be noted that any instances of this object that already exist in the room may not be affected by these functions, but all new instances of this object created in the room will be, so it is recommend that you never change an objects properties when instances of that object are present in the current room.

  1. object_set_depth
  2. object_set_mask
  3. object_set_persistent
  4. object_set_solid
  5. object_set_sprite
  6. object_set_visible
This was what worried me. Could you explain the difference between what you said vs this —confused...
 
H

Homunculus

Guest
The phrase refers to changing the object properties using those functions while the game is running.

Simple example: suppose that you have obj_enemy that is set to visible, and while playing you create a couple of instances of that object using instance_create. Later, you call object_set_visible(obj_enemy, false).
This does not make the enemies currently in the room invisible, but changes the “blueprint” for the new ones, so from now on new instances of obj_enemy when created will be invisible (until you close the game or use obj_set_visible again).

Note that all the above, as said, applies only at runtime.

I am unsure though if entering a room with instances defined through the room editor will consider those as “new” and get created invisible as well (i think so) but should be easy enough to test.
 
The phrase refers to changing the object properties using those functions while the game is running.

Simple example: suppose that you have obj_enemy that is set to visible, and while playing you create a couple of instances of that object using instance_create. Later, you call object_set_visible(obj_enemy, false).
This does not make the enemies currently in the room invisible, but changes the “blueprint” for the new ones, so from now on new instances of obj_enemy when created will be invisible (until you close the game or use obj_set_visible again).

Note that all the above, as said, applies only at runtime.

I am unsure though if entering a room with instances defined through the room editor will consider those as “new” and get created invisible as well (i think so) but should be easy enough to test.
OOOHHHHHHHHHHH...
 
J

jr carey

Guest
a different way to achieve this is by using the instance ID and changing variables, like:

time = 50
var inst = instance_create(x,y,instance)
var inst2 = instance_create(x,y,instance)
inst.time = 10
inst2.time = 900
 
Top