• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[General] Text Tags not centered

Status
Not open for further replies.
Level 15
Joined
Oct 29, 2012
Messages
1,474
No, your PC isn't glitched or something. What's happening is really logical. The unit's position is actually the very origin of the unit, probably centered between the leg (unless it's some alien, or a horse). So when creating floating text tags , the direction is always from the left where the position of unit is, towards the right (Since Warcraft is a left-2-right's lang'ed)

The only way , is what "KILLCIDE" has stated, which is to use the "Polar Offset" option.

This is an image (Never get surprised by my drawing skills) :

JdGJk.jpg
 
Level 15
Joined
Sep 29, 2008
Messages
363
I've used this function to display centered text above items/units and it works well.

JASS:
function DisplayTextTag takes string s ,real x, real y returns nothing
    local integer len = StringLength(s) * 3
    local real life = len / 7.5
    local texttag txt = CreateTextTag()
        call SetTextTagTextBJ(txt, s, 8)
        call SetTextTagPos(txt, x - len, y, 100)
        call SetTextTagColor(txt, 255, 255, 255, 220)
        call SetTextTagPermanent( txt, false )
        call SetTextTagLifespan( txt, life )
        call SetTextTagFadepoint( txt, 3.00 )
        call SetTextTagVelocityBJ( txt, 0, 90 )
    set txt = null
        
endfunction

the "life" var and length var are directly related to font size, (size 8 in this case). Hope it helps you to found a better way
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
Yes, centering texttag is a very painful process.
It can also depends on your camerasetup distance, ( I realised this today while working on my UIpackage. )
aswell as the resolution you use in warcraft.

In vJass exists StringLength from PurgeandFire to get an accurate size of a string.
In GUI you could use something like the code posted from Avahor to estimate a string lenght.

In my opinion a perfect texttag position is not so important in your Heal Event resource.
Important is that a user can see to which unit the texttag belongs.

Ps: When using \n it gets really funny.
 
Status
Not open for further replies.
Top