Mr Awesome
Member
Good afternoon,
I wanted to create three different instances (obj_chicken,obj_chicken_1,obj_chicken_2) at different predefined y coordinates stored in a list. The x is always the same (384), but I want the y to differ and when one y value is used then I don't want it to be used again.
From previous help received I have made a list which stores the three y coordinates and pulls them out randomly (the comments are for me and if they are wrong, please let me know):
But how would I make the next instance in a different Y position? If I just created another instance with the same instance create code right after the first, would it automatically use a different Y value? That is to ask, if the first instance is created at y(32), is there a chance the next instance could also be created at y(32)?
Or do I have to destroy the list and then create it again without storing y(32)?
Any help would be appreciated. Thanks.
I wanted to create three different instances (obj_chicken,obj_chicken_1,obj_chicken_2) at different predefined y coordinates stored in a list. The x is always the same (384), but I want the y to differ and when one y value is used then I don't want it to be used again.
From previous help received I have made a list which stores the three y coordinates and pulls them out randomly (the comments are for me and if they are wrong, please let me know):
Code:
coord_list = ds_list_create();
ds_list_add(coord_list,[32]);//stores the y coord
ds_list_add(coord_list,[192]);//stores the y coord
ds_list_add(coord_list,[352]);//stores the y coord
var rand = irandom(ds_list_size(coord_list)-1);//randomly assigns a Y coord a number
var pos = coord_list[| rand];//stores the y coord number in pos
var yy = pos[0];stores the y coord number in pos in var yy
instance_create_layer(384,yy,"instances",obj_chicken)
Or do I have to destroy the list and then create it again without storing y(32)?
Any help would be appreciated. Thanks.
Last edited: