今日は増殖するゾンビを実装します。前回、地形の生成と追いかけてくるゾンビを実装したので続きから行きますね。
Unityのチュートリアルを参考にすれば簡単。
ゾンビを生まれる場所とスクリプト
Hierarchy -> Create Emptyしてオブジェクト名をZombieSpawnPointにし、Inspectorでキューブから赤い吹き出しに変更しておきます。

Position X:223.52, Y:164.78, Z:220.17に設定。Terrainで作ったフィールドがでかすぎて良い感じの位置を探すのが大変。。
再びHierarchy -> Create Emptyしてオブジェクト名をEnemyManegementにして、座標をresetします。

Add Componentして、ゾンビを一定間隔で産み落として増殖させるスクリプトを書きます。
EnemyManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyManager : MonoBehaviour
{
public GameObject enemy;
public float spawnTime = 3f;
public Transform[] spawnPoints;
void Start ()
{
InvokeRepeating ("Spawn", spawnTime, spawnTime);
}
void Spawn ()
{
int spawnPointIndex = Random.Range (0, spawnPoints.Length);
Instantiate (enemy, spawnPoints[spawnPointIndex].position, spawnPoints[spawnPointIndex].rotation);
}
}
最初からいるゾンビを1体にして、ZombieSpawnPopintらへんに配置します。合わせてPlayerも近くに配置するとこんな感じになります。

これで準備OK。
WEBで公開
今日はUnityで作ったアプリをWEBで公開してみます。
Build Settings -> Platform -> WebGLを選択してSwitch Platformします。
以下のような感じで、何かとエラーが出るので一旦Oculus Integrationをごっそり削除するとビルド出来るようになります。
Assets/Oculus/LipSync/Scripts/OVRLipSyncMicInput.cs(104,13): error CS0103: The name 'Microphone' does not exist in the current context
ビルド出来たらhtmlファイルも吐かれるので好きなホスティングサービスにのっければ出来上がり!
湧き出るゾンビ体験が出来ます!
