hello im new in unity,please help me… i have three object,one is for life,one for player and another one is as a enemy,when the player hit the enemy,i want to destroy object that is player life…all object i using cube…i made some js scipt
function OnCollisionEnter(col : Collision)
{
Destroy(gameObject.FindWithTag('life'));
}
i attached this script into enemy,is it true??
i want to destroy another cube called it "life"..i already try using your code,but it destroy the enemy,what i want to destroy life cube..and i try using this "Destroy(GameObject.FindGameObjectWithTag("life"));"......but this error come out.."UnityException: Tag: life is not defined! collision.OnCollisionEnter (UnityEngine.Collision col) (at Assets/collision.js:8)"
– metallurgicalIn about 99.9% of the cases the answer of an error is in the error. You are part of those 99.9%. " life is not defined" You have not defined life in the tag list nor have you assigned it to the object. Since it does not exist. Again, you cannot just create things on the fly. Or make sure it is not Life.
– fafasesorry,, i dont know how to defined it.. what u mean in the tag list??? can u give some example???
– metallurgicalhttp://answers.unity3d.com/questions/36212/how-do-i-add-a-new-tag-in-unity.html
– fafasenow i now where is tag lies...but,how can i choose those tag,it dont give me an option to choose it...???
– metallurgical