Spawning prefabs in front of the player

So what i am trying to do is make a script that tracks the player’s movement and spawns in front of him random prefab obstacles around 20 units ahead of him (just out of his line of sight) and I am not sure how to do that since the current script only spawns the object at the initial location of the player and that’s all.
Second thing would be how to spawn the ground for the player a few units before he reaches the end of the first ground.

public GameObject prefab1, prefab2, prefab3, prefab4, prefab5;

public float SpawnRate = 0f;

public GameObject myPlayer;

private Vector3 GetXAxis()
{
    return new Vector3(myPlayer.transform.position.x, 0, 0);

}
private void Update()
{
    Vector3 xVector = GetXAxis(); // getting that vector from above
}
public float nextSpawn = -3f;


int WhatToSpawn;

private void FixedUpdate()
{
    if (Time.time > nextSpawn)
    {
        WhatToSpawn = Random.Range(1, 3);
        Debug.Log(WhatToSpawn);

        switch (WhatToSpawn)
        {
            case 1:
                Instantiate(prefab1, transform.position = GetXAxis() * Time.fixedDeltaTime * 20 , Quaternion.identity);
             break;
            case 2:
                Instantiate(prefab2,GetXAxis() * 20 * Time.fixedDeltaTime , Quaternion.identity);
                break;
          /*  case 3:
                Instantiate(prefab3, transform.position, Quaternion.identity);
                break;
            case 4:
                Instantiate(prefab4, transform.position, Quaternion.identity);
                break;
            case 5:
                Instantiate(prefab5, transform.position, Quaternion.identity);
                break;
          */
        }
        nextSpawn = Time.time + SpawnRate;
    }
}

}

Vector3 spawnPos = playerPos + offset

in your case offset = new Vector3(0, 0, 20);

Also here is a very basic spawn system i whipping up for ya in about 5 minutes not testing so let me know if it doesnt work.

using UnityEngine;

public class SpawnThing : MonoBehaviour 
{
	public Vector2 xRange;
	public Vector2 yRange;
	public GameObject[] objectsToSpawn;
	public float spawnRate;
	public float distanceToSpawnFromPlayer;
	public Transform player;

	private float currentTime;

	void Update()
	{
		if(Time.time > currentTime)
		{
			Spawn(objectsToSpawn[Random.Range(0, objectsToSpawn.Length)]);
			currentTime = Time.time + spawnRate;
		}
	}

	void Spawn(GameObject spawnObject)
	{
		Vector3 spawnPos = player.position;
		spawnPos.x += Random.Range(xRange.x, xRange.y);
		spawnPos.y += Random.Range(yRange.x, yRange.y);
		spawnPos.z += distanceToSpawnFromPlayer;

		Instantiate(spawnObject, spawnPos, Quaternion.identity);
	}
}