var myZone : int;
function FixedUpdate(){
myZone = this.gameObject.transform.parent.gameObject.GetComponent(EnemyHealth).zone;
}
function OnCollisionEnter(other : Collision){
if(other.gameObject.tag == "Player"){
if(other.GetComponent(Player).zone != 227){
if(other.GetComponent(Player).zone == myZone){
GameObject.Find("SplashScreen").SendMessage("GameOver");
}
}
}
if(other.gameObject.tag == "Enemy"){
Debug.Log("ENEMY : FRIENDLY");
enemyScript = other.gameObject.GetComponent(EnemyHealth);
if(enemyScript.zone == myZone){
if(enemyScript.health <= 0){
GameObject.Find("SplashScreen").SendMessage("GameOver2");
}
}
}
}
Hi. Got this script thats attached to an enemies vision box. If the vision box collides an object tagged player or an object tagged enemy with less than or equal to zero health and in the same zone as its meant to send a message to end the game. It works when it collides with the player. But when it collides with an enemy nothing happens. “ENEMY : FRIENDLY” doesnt even appear in the console so I’m guessing it doesnt register.
The enemy object has a box collider and rigidbody with isKinematic set to true. The visionbox has just a box collider attached. Theyre also tagged as enemy in the editor. The player object has a mesh collider with isTrigger set to true and a rigidbody with isKinematic set to false. It sounds like the player oject shouldnt collide but it does anyway.
So how can I get the second part of my script the part starting other.gameObject.tag ==“enemy”) to work.Thanks Stealth.