- Home /
The question is answered, right answer was accepted
Random Position For GameObject
Using Unity Pro
If you notice in Slender game, there are 8 notes/pages and every time you play, page place in different places. I wanted to do that but I don't know how to make it.
I have 5 information/notes in my game (gameObject)
Answer by clunk47 · Nov 17, 2013 at 02:42 AM
Well, I agree the question is kind of broad and vague, but should not have been closed and considered off topic. Have a look at Random.Range, and use it for each axis on a Vector3. Say all your "notes" will be on the same Y position, but x and z will be random, just for example's sake.
 float x;
 float y;
 float z;
 Vector3 pos;
 void Start()
 {
     x = Random.Range(-25, 26);
     y = 5;
     z = Random.Range(-25, 26);
     pos = new Vector3(x, y, z);
     transform.position = pos;
 }
Just change y = 5; to y = Random.Range(-25, 26); 
Follow this Question
Related Questions
Moving GameObject to various position ? 1 Answer
Spawn game object in random position on screen 1 Answer
Instantiate a GameObject at the position of one of its child objects 1 Answer
spawn game object in random position 1 Answer
How can I calculate and place a GameObject at a random place just outside the camera frustrum? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                