Question by
Game-Enthusiast · Mar 07, 2017 at 03:14 AM ·
airotateenemy aiwaypoint
Enemy AI's body will rotate left or right if waypoint reach and move to another waypoint
Hi i have this WaveSpawner script .. the script is working.. but when enemy AI reach the destination and will make a turn.. the body of the AI is not rotating is more like it face only one direction
Here is my script
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class WaveSpawner : MonoBehaviour {
public Transform enemyPrefab;
public Transform spawnPoint;
public float timeBetweenWaves = 5;
private float countdown = 2f;
public Text waveCountdownText;
private int waveIndex = 0;
void Update ()
{
if (countdown <= 0f)
{
StartCoroutine(SpawnWave ());
countdown = timeBetweenWaves;
}
countdown -= Time.deltaTime;
waveCountdownText.text = Mathf.Round(countdown).ToString();
}
IEnumerator SpawnWave ()
{
waveIndex++;
for (int i = 0; i < waveIndex; i++)
{
SpawnEnemy();
yield return new WaitForSeconds(0.5f);
}
}
void SpawnEnemy ()
{
Instantiate(enemyPrefab, spawnPoint.position, spawnPoint.rotation);
}
}
Comment
Your answer
Follow this Question
Related Questions
How To Stop Enemy Movement During Its Attack Animation 1 Answer
My Raycast2D doesn't work properly 0 Answers
astar pathfinding with groups 0 Answers