0% found this document useful (0 votes)
40 views3 pages

Enemy Spawner Script

Uploaded by

saad3102004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views3 pages

Enemy Spawner Script

Uploaded by

saad3102004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

using System.

Collections;

using System.Collections.Generic;

using UnityEngine;

public class Enemyspawner : MonoBehaviour

public static Transform[] Espawnpoints;

public Transform spawnerp;

public float DBTP;

Transform Sp;

public GameObject Eenmyprefab;

public int index = 0;

public float DBS;

// Start is called before the first frame update

void Start()

Espawnpoints = new Transform[spawnerp.childCount];

for(int i = 0; i < Espawnpoints.Length; i++)

Espawnpoints[i] = spawnerp.GetChild(i);

Sp = Espawnpoints[0];
}

// Update is called once per frame

void Update()

DBTP = Sp.position.x - transform.position.x;

if (DBTP <= DBS && index <= Espawnpoints.Length)

Debug.Log("1st Enemy reached");

next();

void next()

if (index >= Espawnpoints.Length)

Instantiate(Eenmyprefab, Espawnpoints[index].position, Espawnpoints[index].rotation);

index++;

Sp = Espawnpoints[index];

}
}

You might also like