The title sums it up. I’m stuck… giving me the error message when colliding with the enemy:
MissingFieldException: Field ‘UnityEngine.GameObject.active’ not found.
If I change the code to findwithtag for one enemy then the code works fine. but obviously i have several enemies in my game so I need to figure out how to apply this using an array or something… I know it’s probably a simple fix but I’m not seeing it. Any help is appreciated. Here is my code:
private var playerColor : GameObject;
var colors = new Color[2];
var player : GameObject;
function Awake() {
player = gameObject.FindWithTag("Player");
player.animation["RedHit"].wrapMode = WrapMode.Once;
playerColor = gameObject.FindWithTag("ColorFlash");
}
function OnControllerColliderHit(hit:ControllerColliderHit) {
if (!enabled)
return;
var enemyTriggers = GameObject.FindGameObjectsWithTag("EnemyDeathTrigger");
var controllerScript: RedController = GetComponent(RedController);
if (hit.gameObject.tag == "Enemy") {
controllerScript.GetHit();
Time.timeScale = 0.00001;
Physics.IgnoreCollision(gameObject.collider, hit.gameObject.collider);
playerColor.renderer.material.color = colors[0];
player.animation.Stop();
player.animation.Play("RedHit");
player.animation["RedHit"].speed = 1.0/Time.timeScale;
enemyTriggers.active = false; // THIS IS WHERE MY ERROR COMES FROM
yield WaitForSeconds(1 * Time.timeScale);
Time.timeScale = 1.0;
yield WaitForSeconds(1);
playerColor.renderer.material.color = colors[1];
enemyTriggers.active = true;
Physics.IgnoreCollision(gameObject.collider, hit.gameObject.collider, false);
}