using UnityEngine;
using System.Collections;
[RequireComponent(typeof(flipPlayer))]
public class enemyInstantiate : MonoBehaviour
{
public GameObject[] enemies;
public Transform enemyPos;
public GameObject enemyClone;
void Start()
{
enemyPos = GameObject.Find("enemySpawn").transform;
enemyClone = GameObject.FindGameObjectWithTag("Player");
enemySpawn();
flip();
}
public void enemySpawn()
{
int enemyIndex = Random.Range(0, enemies.Length);
Instantiate(enemies[enemyIndex], transform.position, transform.rotation);
}
void flip()
{
enemyClone.GetComponent<flipPlayer>().enabled = true;
}
}
NullReferenceException: Object reference not set to an instance of an object enemyInstantiate.flip () (at Assets/Scripts/enemyInstantiate.cs:32) enemyInstantiate.Start () (at Assets/Scripts/enemyInstantiate.cs:18)
i'm pretty new to Unity 3D And still having trouble, can you please help out with what the problem is and why am i getting a nullReferenceException.
The error occurs in the line (enemyClone.GetComponent().enabled = true;).