Smart way to add border to a text mesh in a 2d environment

Hello! I am making a text mesh in my game project which is a damage number, it looks very good at the moment. But, I would love to add a black border around the text mesh, to add to the pixely style of the game. I’m thinking that I would just instantiate a textmesh child object of the text mesh that is slightly bigger and being behind the original text mesh object. Any smart way to do this?

Here is my code of assigning the textmesh value:

	public float hpLost;	

        void TakeDamage() {
		    TextMesh text = (TextMesh)thing.GetComponent(typeof(TextMesh));
		    text.text = "-" + hpLost.ToString("F1");
    //hpLost is assigned damageDealt from another script.

If you think there is lacking some vital information, please just ask, but there’s not much more to the textmesh :slight_smile:

I found a solution that I consider is temporary, but it does look much better, and I only instantiate two more objects.

This is how my method now looks like. I added two other duplicates of the first textmesh and changed their color to black, and as you can see in the script I offset the Z-value a bit, to add to the illusion that it has a border. These two only add borders for the left and right side of the mesh in theory. But, it does look quite good, and I could make it look even better by just adding more some more if I would find it desirable. The consideration would be performance, of course!

	void TakeDamage() {
		objectSpeed = 60f;
		Vector2 randomDirection = Random.insideUnitCircle * objectSpeed;

		GameObject dicks = Instantiate(textMeshObject,transform.position,Quaternion.identity) as GameObject;
		TextMesh text = (TextMesh)dicks.GetComponent(typeof(TextMesh));
		text.text = "-" + hpLost.ToString("F1");

		GameObject dicks2 = Instantiate(textMeshObject2, new Vector3 (transform.position.x+0.02f,
		                                                              transform.position.z),Quaternion.identity) as GameObject;
		TextMesh text2 = (TextMesh)dicks2.GetComponent(typeof(TextMesh));
		text2.text = "-" + hpLost.ToString("F1");

		GameObject dicks3 = Instantiate(textMeshObject3, new Vector3 (transform.position.x-0.02f,
		                                                              transform.position.z),Quaternion.identity) as GameObject;
		TextMesh text3 = (TextMesh)dicks3.GetComponent(typeof(TextMesh));
		text3.text = "-" + hpLost.ToString("F1");

Any critique on this or a better idea is still rather highly appreciated.