Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class EnemySpawner : MonoBehaviour {
- public GameObject enemyPrefab;
- public float width = 10f;
- public float height = 5f;
- private bool movingRight = true;
- public float speed = 5f;
- // Use this for initialization
- void Start () {
- foreach( Transform child in transform){
- GameObject enemy = Instantiate(enemyPrefab, child.transform.position, Quaternion.identity) as GameObject;
- enemy.transform.parent = child;
- }
- }
- public void OnDrawGizmos(){
- Gizmos.DrawWireCube(transform.position, new Vector3(width, height));
- }
- // Update is called once per frame
- void update(){
- if(movingRight){
- transform.position += Vector3.right * speed * Time.deltaTime;
- }else{
- transform.position += Vector3.left * speed * Time.deltaTime;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement