Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

need help to spawn objects not too close to eachother

$
0
0
hi guys,

I currently use the following snippet to spawn my mushrooms (level-ups) for a 2D sidescroller game.

Code (CSharp):
  1.   void Update()
  2.   {
  3.     if (stopping == false)
  4.     {
  5.       transform.Translate(-Vector3.right * speed * Time.deltaTime);
  6.       mushroom = GameObject.FindGameObjectWithTag("Mushroom");
  7.     }
  8.  
  9.     if (mushroom != null)
  10.     {
  11.       while (stopping == false && count < 6)
  12.       {
  13.         var position = new Vector2(Random.Range(-25f, 120f), Random.Range(-20f, 30f));...
need help to spawn objects not too close to eachother

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>