- Home /
Weird Variable Issue
I didn't know how else to label this.
I've declared a variable called draw like so: var draw: int = 0;
then I instantiate an object: Instantiate(card, transform.position, transform.rotation);
I increase draw via draw++;
Then I change the name of the newly instantiated object by going:
card.gameObject.name = "Card" + draw;
It works fine for every instance EXCEPT the very first one. The first one always puts in one number above the last number draw stopped at. This is between sessions. I've Debug.Log(draw)'d to see what's going on, draw is the proper variable, but no matter what the name will be +1 the last draw in the last session.
I have no idea why this is happening and was wondering if anyone could give me some insight. Thank you.
You should miss some detail here when posting, a DontDestroyOnLoad, use of playerPrefs ... Can you please post the complete code, from what you say it should surely become card1, card2 card3 ...