Hey guys, I have a script that makes my text vertices shake, and when I make the text bold the shake effect just stops.
Here is the code I am using to make my text shake:
if (Dialogs[index].isToShake)
{
dialogText.ForceMeshUpdate();
mesh = dialogText.mesh;
vertices = mesh.vertices;
for (int i = 0; i < dialogText.textInfo.characterCount; i++)
{
TMP_CharacterInfo c = dialogText.textInfo.characterInfo[i];
int index2 = c.vertexIndex;
Vector3 offset = Wobble(Time.time + i);
vertices[index2] += offset;
vertices[index2 + 1] += offset;
vertices[index2 + 2] += offset;
vertices[index2 + 3] += offset;
}
mesh.vertices = vertices;
dialogText.canvasRenderer.SetMesh(mesh);
}
Vector2 Wobble(float time)
{
return new Vector2(Mathf.Sin(time * 70f), Mathf.Cos(time * 70f));
}
How can I make work properly?
Here is a demonstration:
