• 🏆 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!

How can I place text on a unit while it's moving?

Status
Not open for further replies.
Level 18
Joined
Mar 16, 2008
Messages
721
Not sure there's a great way to do this. It would probably involve creating text, destroying it, then recreating it each time the unit moves.

Maybe something like this?
  • refresh text
    • Events
      • Time - timer_Variable_001 expires
    • Conditions
    • Actions
      • Floating Text - Create floating text that reads test above Cenarius 0000 <gen> with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Change the lifespan of (Last created floating text) to 0.11 seconds
      • Countdown Timer - Start timer_Variable_001 as a One-shot timer that will expire in 0.10 seconds
*edited
 

Attachments

  • floating_name_text.w3m
    20.3 KB · Views: 1
Last edited:
It is also possible to set floating text up with 1 trigger (and store it in a variable), then have another one that updates every 0.02 seconds or so and move the text to the unit (must also be in a variable) using "custom script":

  • MoveFloatingText
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Custom script: call SetTextTagPos(udg_my_floating_text, GetUnitX(udg_follow_hero), GetUnitY(udg_follow_hero), 85.0)
The floating text should be stored in "my_floating_text"-variable and the unit "follow_hero" (of course you can edit the custom script to have any variable-name). The 85 is just the "Z-value" or the text, I.E. how high up it is. You can also add an offset from the floating-text if you want by adding " + 25.0" after the "GetUnitX(udg_follow_hero)" or the Y.
 
Level 6
Joined
Oct 25, 2018
Messages
108
How can I place text on a unit while it's moving?

Ícono de validado por la comunidad
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,575
There's a GUI action as well:
  • Floating Text - Change the position of (Last created floating text) to (Last created unit) with Z offset 0.00.
If you want it to work for multiple units then you can do the following:
Use a Unit Indexer or Hashtable to link the Floating Text to each unit.
Then store all of the desired units in a Unit Group.
Then loop over the Unit Group periodically and update the position of each unit's linked Floating Text.
 
Status
Not open for further replies.
Top