Instantiated children wont update position

So I decided to make a game for a school project just for fun, it’s a typical fly around dodge asteroids 2d game. I have run into one problem though. I have created an empty game object with a square that shows the “spawnable” area for the asteroids. But when I move and the camera/the empty game object updates its position. The spawn area for the asteroids won’t, the square will follow the change in position but the asteroids won’t.


I have pasted my script that is basically copied from a youtube video and I will also link a youtube video that I recorded to show more in-depth what I mean


Thanks in advance


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

public class deployDodgebles : MonoBehaviour
{
    public GameObject circlePrefab;
    public Transform positionSpawner;
    public GameObject circles;
    public float respawnTime = 1;

    private void Start()
    {
        StartCoroutine("respawnEnemie");
    }

    private void spawnEnemie()
    {
        circles = Instantiate(circlePrefab) as GameObject;
        circles.transform.parent = positionSpawner.transform;
        circles.transform.position = new Vector2(Random.Range(-13.49813f, 13.49813f), 7.347601f);
    }


    IEnumerator respawnEnemie()
    {
        while (true)
        {
            yield return new WaitForSeconds(respawnTime);
            spawnEnemie();
        }
    }

    private void OnBecameInvisible()
    {
        Destroy(circles.gameObject);
    }
}

That video helped quite a bit. I know its in the early stages but consider naming your circles what they are supposed to be.

Anyway your circles.transform.position = new Vector2(Random.Range() is the problem. Its static. It should be something like (-13f-circles.transform.parent.position, 13f+circles.transform.parent.position) so that the position is relative to the parent position.

use Instantiate(Object original, Vector2 position, Quaternion rotation, Transform parent); where position and rotation will be relative to parent…