• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Changing an instance

J

julkibr

Guest
So I am trying to do an rts kind of approach to my game so i have an object,and I draw 40 instances of it.So the problem i have is that i want to change one,only one of this instances into another object(like a sawmill or a corn field).
 

FrostyCat

Redemption Seeker
Then use an instance ID instead of an object ID, simple as that.

Before you can get at an instance ID, you must first answer the question "Which?" with absolute certainty. That is not apparent from the way you post. Do that first, then find the function or combination of functions that will enable you to get it.

For example, if you want an arbitrary instance:
Code:
with (instance_find(obj_unit, irandom(instance_number(obj_unit)-1))) {
  instance_change(obj_sawmill, true);
}
Or if you want one that your mouse cursor is over:
Code:
with (instance_position(mouse_x, mouse_y, obj_unit)) {
  instance_change(obj_sawmill, true);
}
 
Top