Random Position

Every gameobject has a transform component attached to in unity.

in my game each prefab is instantiated by a spawner script. however they are moving in a linear axis.
Rather i would like them to be spawned in different y axis position randomly.
This is too much complicated and i like to get some help please.
here is my code :

var newTransform = transform;
            GameObjectUtil.Instantiate(prefabs[Random.Range(0, prefabs.Length)],
                newTransform.position);

The above script is simply taking the position for the new GameObject from the Transform of the GameObject this script is located on.

If you want another position, you can make one with new Vector3() and Random.Range calls along the axes of interest to you and pass it into your GameObjectUtil.Instantiate() helper script, or just instantiate it yourself and move it around.

Exactly worked! happy to learn it.