今日は増殖するゾンビを実装します。前回、地形の生成と追いかけてくるゾンビを実装したので続きから行きますね。
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ファイルも吐かれるので好きなホスティングサービスにのっければ出来上がり!
湧き出るゾンビ体験が出来ます!