SOLVED create_instance_layer doubles the amount of objects

YourGrandpa

Member
Hey Gamemaker community,
as the title says i struggle with the create_instance_layer, i made some kind of loop with a counter but as soon one runs trough is complete it doubles the amount of objects created by it which wasnt intended.
Really tried to solve this on my own but i cant get my head around it just doubles. So i hope you guys and girls can help out.

// create event
xRandom = irandom_range(1,10)*32;
yRandom = irandom_range(1,10)*32;
counter = 0 ;

// step event
if(counter == 160){
// creating block at random position
instance_create_layer(xRandom,yRandom,"Instances",objGround);

counter = 0;
} else {
counter++;
show_debug_message(counter);
}



debug output
Entering main loop.
**********************************.
1
2
3
4
5
6
7
8
9
10
11
.....

1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
...
 
You haven't specified what object this code belongs to, but if I had to guess, it's within objGround, which then would make perfect sense.
 

FrostyCat

Member
Child objects copy code from their parent unless otherwise overridden. You should NOT make an object a child of another object just because it is referenced by the other object. Inheritance is an "A is a B" relationship, not an "A talks about B" relationship.
 
Top