Hi … i am working on 2d game in which i have flower which is made with 2d petals(sprites)…totals petals are 30… what i am trying to do when my scenes start it randomly pick 20 to 30 petals and instantiate them on their actual position…i know i can do that with array or list … i have searched and tried but its complicated… below is my solution but its not good… first it instantiate random petals but they are not on there actual position … they overlap eachother second it also instantiate the same petals again … in array we can remove the element which already been instantiated so it do not copy again … but when i try it show me error … its an essay task but i don’t know its complicated for me … …
#pragma strict
var petals : GameObject[ ];
var random: int;
//var location:Vector3= new Vector3(0.9006966,0.5747727,-4);
function Start(){
var random = Mathf.Abs(Random.Range(1,30));
Debug.Log(random);
for (var i:int =1; i<=random; i++){
var petal= petals[Random.Range(0,petals.Length)];
// if (petal==petals[Petal1])
// {
//// location:transform=
// }
var petalClone= Instantiate(petal,transform.position,transform.rotation);
// Destroy(petals*);*
// petals.RemoveAt(i);
- }*
}