Reputation: 45
In my unity platformer game I have got an enemy with a simple patrolling script I would like to have text placed above him and it stays there. How could I go about doing this?
private void FixedUpdate()
{
if(hit.collider != false)
{
if (isFacingRight)
{
rb.velocity = new Vector2(speed, rb.velocity.y);
}
else
{
rb.velocity = new Vector2(-speed, rb.velocity.y);
}
}
else
{
isFacingRight = !isFacingRight;
transform.localScale = new Vector3(-transform.localScale.x, 1f, 1f);
m_Object.transform.localScale = new Vector3(-transform.localScale.x, 1f, 1f);
}
}
Upvotes: 1
Views: 348
Reputation: 614
Use the TextMeshPro
package, and add a TextMesh as a child of the enemy, just above its head. This will keep the text over it
Upvotes: 1