Spawning different objects

Hey i’ve got a problem with spawning randomly objects out of a prefab folder on my screen that is being replaced after it passed the player.

The names of the objects are: wall1, wall2, wall3.

This is the script I use for spawning in the update() but before i used the same in the start() and he don’t want to change it in the update function.

randomWall = Random.Range (1, 4);

GameObject wallPrefab = Resources.Load ("Prefabs/Wall" + randomWall) as GameObject;

The problem is that he only spawns one kind of objects and he doesn’t change it

the meaning is that it becomes an endless runner that random generate some before thought situations after each other.

edit:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class WallManager : MonoBehaviour 
{
	public GameObject runnerRef;
	public float distanceToRecycle = 20;
	public int numberOfWalls = 4;
	public int movement = -5;
	public List<GameObject> wall = new List<GameObject>();
    
	static int randomWall = Random.Range(1,4);

	void Start () 
	{




		GameObject wallPrefab = Resources.Load ("Prefabs/Wall" + randomWall) as GameObject;
		for (int i=0; i<numberOfWalls; i++) 
		{
			GameObject b = Instantiate (wallPrefab, Vector3.zero, Quaternion.identity) as GameObject;
			Vector3 tempPos = new Vector3();
			if(wall.Count>0)
			{
				tempPos = wall[wall.Count-1].transform.position;
				tempPos.x += b.transform.localScale.x*.5f*35;
			}
			b.transform.position = tempPos;
			b.transform.parent = gameObject.transform;
			b.transform.parent.localPosition = new Vector3(30,12,20);
			wall.Add(b);
		}
	}
	// Update is called once per frame
	void Update () {

		randomWall = Random.Range (1, 4);
		Debug.Log (randomWall);

		transform.Translate (new Vector2 (movement * Time.deltaTime, 0));

		if (wall [0].transform.position.x + distanceToRecycle < runnerRef.transform.position.x) 
		{
			GameObject b = wall[0];
			wall.Remove(b);


			GameObject wallPrefab = Resources.Load ("Prefabs/Wall" + Random.value * 2 + 1) as GameObject;


			Vector3 tempPos = new Vector3();
			if(wall.Count>0)
			{
				tempPos = wall[wall.Count-1].transform.position;
				tempPos.x += b.transform.localScale.x*.5f*35;
			}
			b.transform.position = tempPos;
			b.transform.parent = gameObject.transform;
			//b.transform.parent.localPosition = new Vector3(30,12,20);
			wall.Add(b);
		}
	}
}

[26424-screen+shot+2014-05-10+at+00.55.40.png|26424]

I believe your problem is here:

 GameObject wallPrefab = Resources.Load ("Prefabs/Wall" + Random.value * 2 + 1) as GameObject;

Instead of using ‘randomWall’ as you do in Start(), you are using some other calculation. Note that Random.value will always be between 0 and 1.