ただ、出現場所は、固定されてしまうので
ある地点の周辺にランダムに出現できるようにしたい
Hierarchy>EnemyGenerator>EnemyGeneratorCtrlの
Positionをx5y3z7にする
EnemyGenerator.csの void Generate()を以下のように変更
void Generate()
{
for(int enemyCount = 0; enemyCount < existEnemys.Length; ++ enemyCount)
{
if( existEnemys[enemyCount] == null ){
float EnemyPosX = transform.position.x+Random.Range(-5,5);//x軸方向の調整
float EnemyPosY = transform.position.y;
float EnemyPosZ = transform.position.z+Random.Range(-5,5); //y軸方向の調整
//Enemy.transform.position=transform.position;
Vector3 EnemyPos = new Vector3(EnemyPosX,EnemyPosY,EnemyPosZ);
existEnemys[enemyCount] =
Instantiate(enemyPrefab,EnemyPos,transform.rotation) as GameObject;
return;
}
}
}
- 関連記事
-
YouTubeで動画を定期的に出しています。ご視聴いただけると嬉しいです。
Reon Labo
- 2016/12/30(金) 18:00:00|
- Unity
-
| トラックバック:0
-
| コメント:0