Comments and answers for "random place generator"
http://answers.unity.com/questions/1625939/random-place-generator.html
The latest comments and answers for the question "random place generator"Comment by DCordoba on DCordoba's answer
http://answers.unity.com/comments/1626184/view.html
I forgot to Random.Range(min, max) is with min inclusive *but* max exclusive so, x axis always will be 0...
ammm, sorry, my bad xd
try, `a.transform.position = new Vector2((Random.Range (0,2))*screenBounds.y * 2, Random.Range(-screenBounds.x, screenBounds.x));`
this will do random between 0 and 1
also please provide info about camera location, I believed, purely empiric to (0,0) was on the left-bottom part of the scene... this doesnt seem to be the case, so...
lets make it jump between two fixed values, (-1 and 1) if your camera is centered on 0 this... should work
int randYFromN1To1 = 2*(Random.Range (0,2)) - 1; //this jump between -1 and 1 without touch intermediate values
transform.position = new Vector2 ((randYFromN1To1)*screenBounds.y * 2, Random.Range (-screenBounds.x, screenBounds.x));Fri, 26 Apr 2019 17:51:59 GMTDCordobaAnswer by Dimitris4
http://answers.unity.com/answers/1626107/view.html
@DCordoba its not the same except instead of spawning on the sides it spawns in the middle. Any other idea?Fri, 26 Apr 2019 12:03:39 GMTDimitris4Comment by DCordoba
http://answers.unity.com/comments/1625994/view.html
the problem is there
a.transform.position = new Vector2(screenBounds.y * 2, Random.Range(-screenBounds.x, screenBounds.x));
if you see on your global space, problably **x axis** is the **horizontal axis** , try some like
a.transform.position = new Vector2((Random.Range (0,1))*screenBounds.y * 2, Random.Range(-screenBounds.x, screenBounds.x));
`(Random.Range (0,1)`returns a `int` either 0 or 1, not a float value betweem them so, the aliens will spawn on the left `y = 0` or right `y = screenBounds.y*2`Thu, 25 Apr 2019 23:59:56 GMTDCordoba