Spawn position

I am new to unity just trying to learn a bit by making a space shooter game. I am trying to get obstacles to spawn ahead of my player, but it keeps spawning at the same position no matter my player position. I cant see what I did wrong. I copied and pasted the code from part of my project that is working and i still cant get it to work. Thank you for any help. I am sure I am missing something simple.

I save the player position in this script.

public class Player : MonoBehaviour {
    public static float playerZPos; // i save players z position here
    private Transform myTranform;
    public float playerSpeed = 5;
    public static float distance = 0;

    private float dis = 30;
    // Use this for initialization
    void Start () {

        myTranform = transform;

        myTranform.position = new Vector3(0, 0, 0);

	// Update is called once per frame
	void Update () {
        // Debug.Log(myTranform.position.z);

        //makes player move forward
        myTranform.Translate(Vector3.forward * playerSpeed * Time.deltaTime);

        //move player left and right
        myTranform.Translate(Vector3.right * playerSpeed * Input.GetAxis("Horizontal") * Time.deltaTime);

        //move player up and down
        myTranform.Translate(Vector3.up * playerSpeed * Input.GetAxis("Vertical") * Time.deltaTime);

        //curent z position
        playerZPos = myTranform.position.z;

        //set distance equal to your z position
        distance = playerZPos;

        if(playerZPos > dis)
            Debug.Log("player distance" +playerZPos);
            dis += 20;


this is the code i use to spawn the obsticle

public class Spawner : Player {

    public float deathTimer;
    public float spawnDelay = 2;
    float size;

    public Transform AstriodOnePref, AstriodTwo, AstroidThree;

    int randEnemy;

	// Use this for initialization
	void Start ()
        float spawnRate = 2;

        //calls the method to spawn obstacle
        InvokeRepeating("ObstacleSpawnerA", .5f, spawnRate);
	// Update is called once per frame
	void Update ()


    void ObstacleSpawnerA()
        //pick random number to determine size
        size = Random.Range(3.5f, 5);

        //spawn new astroid 
        Instantiate(AstriodTwo, new Vector3(Random.Range(-5, 5), -3, playerZPos + 35), Quaternion.identity);
        AstriodTwo.transform.localScale = new Vector3(size, size, size);


Hey mate, good start! You need a couple changes here. When using static variables you still have to state what class it’s coming from. Also you’re changing the scale of your AsteroidTwo prefab there, what you want to be doing is changing the scale of the instance that you spawn. Try this:

Gameobject asteroidClone = Instantiate(AstriodTwo, new Vector3(Random.Range(-5, 5), -3, Player.playerZPos + 35), Quaternion.identity);
asteroidClone.transform.localScale = new Vector3(size, size, size);