Hierarchy unity3d
Hello, guys. I need Your help. In Hierarchy Unity had started to add numbers and it ruins my script. In script I have:
void OnCollisionEnter2D(Collision2D col){
if (col.gameObject.name == "Enemy 1" || col.gameObject.name == "SAW" || col.gameObject.name == "END")
Application.LoadLevel (Application.loadedLevel);
}
And it works perfectly fine. But when I'm adding new objects or prefabs Unity add numbers to it. How may I change it?
Hope You will help. Thank You.
Guys I have solved this problem.
Here is solving way:
1) You have to crate Tag and apply it to Your Prefabs - in my case it's tag "Obstacles"
2) You are writing it to Your script:
void OnCollisionEnter2D(Collision2D col){
if (col.gameObject.tag == "Obstacles")
Application.LoadLevel (Application.loadLevel1); }
Answer by Dave-Carlile · Sep 17, 2015 at 12:08 PM
After you instantiate the object just set the name.
GameObject o = Instantiate(...);
o.name = "SAW";
Hello, Dave. But I don't Instantiate objects I'm drugging them from Prefabs folder.
Your answer
Follow this Question
Related Questions
Bacteria/Cell Growth 1 Answer
Find Number Multiple within Range 0 Answers
Var GameObject not considering Clones. 0 Answers
WARNING: 1853030816 format is not supported, decompressing texture. 1 Answer