- Home /
Help with string to gameObject.name
I try this:
void OnCollisionEnter(Collision col)
void OnCollisionEnter(Collision col)
{
situationjump = (""+gameObject.name ""+col.gameObject.name);
}
But I get an error
Error 3 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
Comment
if this is C#, your missing one " + "
("" + gameObject.name + "" + col.gameObject.name);
Answer by VesuvianPrime · Sep 24, 2014 at 10:29 AM
It looks like you're just missing an addition. You can avoid these kinds of errors by using string.Format:
string.Format("{0}{1}", gameObject.name, col.gameObject.name);
Answer by dmg0600 · Sep 24, 2014 at 10:52 AM
You are missing a + after gameObject.name:
void OnCollisionEnter(Collision col)
{
situationjump = ("" + gameObject.name + "" + col.gameObject.name);
}
Your answer
Follow this Question
Related Questions
Return name of file only 1 Answer
String as Variable name 0 Answers
Find a child with a name, how to?? 5 Answers