Unity 4.6 Stop Canvas from flipping

I’m trying to create a flexible little speach bubble attached to my player. To do this I have added a canvas to my player entity with UI Text on it. The canvas is then set to “World Space” so that it follows the player along as he moves. This works fine:

41371-normal.png

To make the player walk the other way I use a Flip() method which flips the transforms localScale
like this

void Flip()
{
	faceright = !faceright;
	Vector3 theScale = transform.localScale;
	theScale.x *= -1;
	transform.localScale = theScale;
}

Problem with this is it flips my canvas and I end up with this:

41372-flip.png

How do I stop this from happening? I have tried all sorts of things and none seem to give me the correct solution. I have tried reverting the child transform locale scale by adding something like this to the Flip method

	foreach (Transform child in transform)
	{
		Vector3 childScale = child.localScale;
		childScale.x = Mathf.Abs(childScale.x);

		child.localScale = childScale;
	}

And I also tried adding a billboard script to the Canvas to make it look at the camera each update:

public class Billboard : MonoBehaviour 
{
	Camera _camera;
	
	void Start() {
		_camera = Camera.main;
	}
	
	void Update()
	{
		transform.LookAt(transform.position + _camera.transform.rotation * Vector3.forward,
		                 _camera.transform.rotation * Vector3.up);
	}
}

I think my anchors etc are all wrong in the canvas but I’m totally out of my depth. Anybody know what I’m doing wrong/not doing?

You are flipping the parent object so anything below the hierarchy will flip with it.

Make your top object a controller object with the text mesh as one child and the sprite as another child.

Then you can independently flip things:

[SerializeField] private Transform playerTr = null; // Drag sprite object in there

 void Flip()
 {
     faceright = !faceright;
     Vector3 theScale = playerTr.localScale;
     theScale.x *= -1;
     playerTr.localScale = theScale;
 }

@CrimsonChin:
You can keep your setup as it is. Just add a transformation to your canvas in your script same as the players transformation:

Also remember to flip back the canvas along with your player.

public GameObject canvasBoard; // variable


transform.localScale = theScale;
canvasBoard.transform.localScale = new Vector3(-1,1,1) // add this after your player transform.