Advertisement
carrot_soup

Untitled

Feb 17th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class EnemySpawner : MonoBehaviour {
  5. public GameObject enemyPrefab;
  6. public float width = 10f;
  7. public float height = 5f;
  8. private bool movingRight = true;
  9. public float speed = 5f;
  10.  
  11.  
  12. // Use this for initialization
  13. void Start () {
  14. foreach( Transform child in transform){
  15. GameObject enemy = Instantiate(enemyPrefab, child.transform.position, Quaternion.identity) as GameObject;
  16. enemy.transform.parent = child;
  17. }
  18. }
  19.  
  20. public void OnDrawGizmos(){
  21. Gizmos.DrawWireCube(transform.position, new Vector3(width, height));
  22. }
  23. // Update is called once per frame
  24. void update(){
  25. if(movingRight){
  26. transform.position += Vector3.right * speed * Time.deltaTime;
  27. }else{
  28. transform.position += Vector3.left * speed * Time.deltaTime;
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement