Question by 
               dhrupad · Jul 01, 2016 at 03:21 PM · 
                movementrandomgenerationrandomspawningrandomization  
              
 
              how to randomly move each generated clone?

I need to move each generated food clone in to random position, those random small dots generated on game window are food clone.
this down below is code for food clone generation.
 using UnityEngine;
 using System.Collections;
 
 public class food : MonoBehaviour {
 
     public GameObject Food;
     public float speed;
      
     void Start()
     {
         InvokeRepeating("Generate", 0, speed);
     }
 
     void Generate()
     {
 
         int x = Random.Range (0, Camera.main.pixelWidth);
         int y = Random.Range (0, Camera.main.pixelHeight);
 
         Vector3 target = Camera.main.ScreenToWorldPoint(new Vector3(x, y, 0));
         target.z = 0;
 
         Instantiate(Food, target, Quaternion.identity);
 
     }
     }
 
 
               
                 
                img-smpl.png 
                (322.9 kB) 
               
 
              
               Comment
              
 
               
              Your answer