- Home /
object name disappearing!!
Hi i am writing a bit of code so that when my character named: "Joe" runs into this object, it will print a string this is that:
void OnTriggerEnter (Collider col) { col.gameObject.name = charactersName;
if(col.gameObject.name == "Joe")
{
print("yah");
charactersName = "Joe";
}
}
My Character has a box collider on it, and when the runtime starts.. the name of the object disappears.. Why is this?!?!?
this is where it disappears:
Answer by saschandroid · Nov 13, 2015 at 08:30 AM
You are setting
col.gameObject.name = charactersName;
right before the if-condition. So if charactersName
is empty ("") the name of the game object got lost in OnTriggerEnter
.
Your answer
Follow this Question
Related Questions
How do I display the objects collider box in a running scene 2 Answers
Collider added far from object 1 Answer
How would I make an object disappear after a set amount of time? 3 Answers
Object falls through terrain 1 Answer
Need some help an object collider that stops a timer then displays it on another scene 1 Answer