Guest User

Untitled

a guest
May 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.AI;
  5.  
  6. public class CreateEnemy2_1 : MonoBehaviour
  7. {
  8. public int MaxEnemyCount; //敵の最大数
  9. public Vector3 CreateRange; //敵を作る範囲
  10. public Transform CreateEnemy2_1T; //敵を発生させる原点
  11. public GameObject Enemy1Obj; //Enemy1オブジェクト
  12.  
  13. // Use this for initialization
  14. void Start ()
  15. {
  16. for(int i = 0; i < MaxEnemyCount; i++)
  17. {
  18. GameObject Enemy1Objs = Instantiate(Enemy1Obj); //敵を生成
  19. float RandomCreateX = Random.Range(-CreateRange.x, CreateRange.x); //生成する範囲からランダムな座標を決める(X軸)
  20. float RandomCreateZ = Random.Range(-CreateRange.z, CreateRange.z); //生成する範囲からランダムな座標を決める(Z軸)
  21. Vector3 RandomCreate = new Vector3(RandomCreateX, 0, RandomCreateZ); //代入
  22. Enemy1Objs.transform.position = CreateEnemy2_1T.position + RandomCreate; //敵の発生場所を決める(発生させる原点にランダムに生成する範囲を足す)
  23. Enemy1Objs.GetComponent<NavMeshAgent>().enabled = true; //インスタンスと同時にNavMeshAgentを有効にする
  24. }
  25. }
  26.  
  27. // Update is called once per frame
  28. void Update ()
  29. {
  30.  
  31. }
  32. }
Add Comment
Please, Sign In to add comment