Reputation: 99
In GMS2 I have a spawner item with the following code:
In the create event:
timer = 0;
In the step event:
if(distance_to_object(obj_coffe_bean) > 2)
if(timer == 200) {
instance_create_layer(x, y, obj_coffe_bean, obj_coffe_bean);
timer = 0;
}
else timer++;
This works perfectly fine, coffee beans are spawned when it doesn't detect any coffee bean nearby.
The problem is that the same code doesn't work when I duplicate this object and create a spawner for another item.
Upvotes: 0
Views: 472
Reputation: 99
Ok, I needed to use instance_create_depth instead of instance_create_layer.
Upvotes: 0
Reputation: 3202
The most obvious problem here would be that you are using the object index as the layer index in instance_create_layer - your code only works by chance (of there being a layer with a matching ID).
Upvotes: 2