Drawing name CENTERED over players head

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

robert123

New Member
Nov 8, 2003
41
0
0
Hi, I wanted to be able to draw the player name over the head of the player. I managed to do this, but I still don't know how to render it centered over the players position. Do you know how can I acchieve this?

Currently rendered text:
Code:
     PlayerName
    O
  -||-
   / \

What I want:
Code:
PlayerName
     O
   -||-
    / \

Thanks
 

robert123

New Member
Nov 8, 2003
41
0
0
If I could get the width of the drawn text, I could calc the new position, but I don't know how to do that.
 

robert123

New Member
Nov 8, 2003
41
0
0
That would return me the size of the string in characters, what I need is the width of the string in pixels...
 

emailer33

New Member
May 23, 2002
40
0
0
38
Visit site
Code:
float XL, YL;
Canvas.TextSize("PlayerName",XL,YL);
Canvas.SetPos(PlayerLocationX-(XL/2),PlayerLocationY);
Canvas.DrawTextClipped("PlayerName");

gives ya what you want and should be easy enuf to understand.
i've used this many a time and it always produced fine results.