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

Member
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