Hey guys I am making a game with 3 enemy’s how do I get all there names with gameObject.name in code I cant use GameObject.findwithtag as I am using OnCollisionEnter
thx
[code if needed]
var hurt : AudioClip;
var playerhealth :int =3;
var playerheath1 : Texture2D;
var playerheath2 : Texture2D;
var playerheath3 : Texture2D;
var score :int =0;
function OnCollisionEnter(other : Collision) {
if(other.gameObject.name =="bird(Clone)"){
playerhealth--;
audio.PlayOneShot(hurt);
if(playerhealth == 0)
GameOver();
}
}
function OnGUI () {
if(playerhealth ==3)
GUI.Label (Rect (60, -16, 200, 200),playerheath1);
if(playerhealth ==2)
GUI.Label(Rect (60, -16, 200, 200),playerheath2);
if(playerhealth ==1)
GUI.Label(Rect (60, -16, 200, 200),playerheath3);
}
function GameOver () {
Application.LoadLevel("Skydiving game");
if(score > PlayerPrefs.GetInt("score")){
PlayerPrefs.SetInt("score",score);
}
}