Randomly Generated Objects

In my game the player must go between 2 objects (goal poles). I don’t know how to spawn them randomly in.

There is 3 sets of poles: Left,Center,Right.

I want the left ones to be at -25,0,N.

I want the center ones to be at 0,0,N.

I want the right ones to be at 25,0,N.

In which N is equal to how far “forward” the player has gone.

22047-goalposts.png

EDIT: I want the Z axis to change 35 every time a new set of poles is added
for example:
Pole 1 = 0,0,0
Pole 2 = -25,0,35
Pole 3 = 0,0,70
Pole 4 = 0,0,105

But I want it to spawn randomly every time.

Keep a variable that stores the z-coordinate of the last-spawned goal. Then when you spawn a new goal, set its position with:

mySavedZ = mySavedZ + 35f;
float randomX = Random.value;
float spawnX;
if (randomX<0.3333f) {
    spawnX = -25f;
}
else if (randomX<0.6666f) {
    spawnX = 0f;
}
else {
    spawnX = 25f;
}
Vector3 newPosition = new Vector3(spawnX,0f,mySavedZ);

You can then set its position with newPosition.