Print String And Variable In Same Line

Okay, so say I have two objects. One is named Ball1 and the other is Ball2. So in my script I have a “var x = 2;”. So I want to print the word ball and the variable to the console. For example, I want to print, “Ball2” to the console, but I want this line of code:

Debug.Log(“Ball”(x));

Now obviously this isn’t right, but I’m pretty sure you have an idea of what I want to do. Any help?

2 Answers

2

Debug.Log(“Ball” + x);

If you add an integer or a float to a string it all becomes a string.

Just concatenate the string and the variable:

Debug.Log("Ball "+x);