Updating a TextMesh buggy?

I’m using a for-loop to assign RP/M values to a textmesh, it is updating once per second but keeps getting weird values.

the highest RPM value in my records is a 4 digit number and it goes up to way more than that…

example :

myEpicTextMesh.Text = int.Parse(MyEpicRpmArray[EPIC]).ToString(MyEpicRpmArray[EPIC] + " RPM");

doing this in a coroutine once per second getting weird numbers…

any advice on fixing this?

any help is apreciated

thanks in advance,

bio

Your quoted code does this:

  1. Implicitly convert MyEpicRpmArray[EPIC] to a string in order to…
  2. Pass that string to int.Parse to convert (back) to an integer.
  3. Again convert MyEpicRpmArray[EPIC] to a string in order to add " RPM" to it.
  4. Uses that value as a string format specification to int.ToString
  5. int.ToString formats the int from step 2 according to the string from step 3
  6. Produces a weird mess, since step 3 does not produce a sensible format.

So try instead simply:

myEpicTextMesh.text = MyEpicRpmArray[EPIC] + " RPM";