Hello,
I need help creating a game. I want to have a character on the bottom of the screen of my 2D game, and I want balls to be spawned randomly from the left and right walls. Now, everything is good so far, however I do not have any idea how to clone my already existing balls objects,randomly on the edge of the screen(right or left).
Any help?
Thank you!
You would need to Instantiate a prefab/gameobject in a range of two values.
For example:
Instantiate (ball, Vector3(Random.Range(1,10), 0, 0), Quaternion.identity);
This code would clone a prefab (that you would have set in the inspector), and place it between the walls at a random position, 1 to 10. And Quaternion.identify would just set the rotation of the object.
Hope this helps.
–LucasMars