I don’t know if I exactly worded my question correctly but here is my issue. I have a multiplayer game where all the players tagname is displayed hovering over its character object in 3D. The hover text is a UI text object in world space. The text is a child of the character object and is always above the character.
How can make this text stay in 2D coordinates and not rotate when the character rotates. Want to make the text just always face the screen without rotating…
Not sure how Canvas is going to react to simple transform events, but I have a couple of ways in my mind that you can try :
Use LookAt to face the transform of the UI to player.
private Transform player;
void Start()
{
player = GameObject.FindGameObjectWithTag("Player").transform;
}
void Update()
{
Vector3 lookAtPos = player.position;
lookAtPos.y = transform.position.y; // this will make the UI to rotate only X-Z axis according to player.
transform.LookAt(lookAtPos);
}
Use Quaternion Look Rotation to face the transform of the UI to player. Which is given with a good example over reference page.