Following Floating Text?

Status
Not open for further replies.
Level 18
Joined
Jun 2, 2009
Messages
1,276
Hello everyone. I am experimenting on Floating Text and i am trying to make it follow specific unit. This one is not working somehow.

  • Untitled Trigger 001 Copy
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Floating Text - Create floating text that reads HERO above Paladin 0002 <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 the color of (Last created floating text) to (100.00%, 0.00%, 0.00%) with 0.00% transparency
      • Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
      • Wait 2.00 seconds
      • Floating Text - Destroy (Last created floating text)
First one appears at second 2 and stays PERMANENT. Then other texts appears and vanishes immediately.

I want to make it follow the unit. How can i do that?
 
You don't have to use Destroy if you're setting a lifespan, to make the lifespan work though you also have to add:
  • Floating Text - Change (Last created floating text): Disable permanence
The reason the first text remains permanently is because Wait is not accurate, so it takes slightly longer than 2 seconds. You set the trigger to run every 2 seconds as well, so when the trigger runs for the first time and has waited (slightly longer than) 2 seconds, the trigger has already started a second time, so last created floating text no longer refers to the first created text.
 
You don't have to use Destroy if you're setting a lifespan, to make the lifespan work though you also have to add:
  • Floating Text - Change (Last created floating text): Disable permanence
The reason the first text remains permanently is because Wait is not accurate, so it takes slightly longer than 2 seconds. You set the trigger to run every 2 seconds as well, so when the trigger runs for the first time and has waited (slightly longer than) 2 seconds, the trigger has already started a second time, so last created floating text no longer refers to the first created text.

I understand. But still i don't get it how to make it follow :D

I think you can put an expiration on floating text, am I wrong? Seems like that would be ideal.
Otherwise, I would check if there is a way to save the floating text as a variable.
No idea. But still i cannot make it work.
How can i make a floating text on "moving unit" permanently?
 
I understand. But still i don't get it how to make it follow :D


No idea. But still i cannot make it work.
How can i make a floating text on "moving unit" permanently?
It should work if you remove the wait and destroy actions, and add the action that I mentioned.

The alternative solution is that you store the floating text in a variable instead of creating a new one every 2 seconds. Then you need two triggers, one to create/initialize the floating text, and another one to move the text to its new location.
 
Floating text doesn't have a function to make it follow units. You have to reposition it yourself:
  • Floating Text - Change the position of YourText to YourUnit with Z offset 0.00.
You then use a Timer/Periodic Interval to periodically reposition the text yourself.

If you want multiple units to have their own floating text then you can use a Unit Indexing system. This allows you to link the text and the unit together:
  • Actions
    • Set Variable TextUnit = some unit
    • Floating Text - Create floating text above TextUnit...
    • Set Variable Text[custom value of TextUnit] = Last created floating text
    • Unit Group - Add TextUnit to TextGroup
  • Events
    • Time - Every 0.01 seconds
  • Conditions
  • Actions
    • Unit Group - Pick every unit in TextGroup and do:
    • Loop - Actions:
      • Floating Text - Change the position of Text[custom value of (Picked unit)] to (Picked unit) with Z offset 0.00.
It's smart to design these triggers in a way that unwanted units are removed from TextGroup and the Periodic trigger is turned off while the group is empty.

Variables:
TextUnit = unit
Text = floating text
TextGroup = unit group

You can also use a Hashtable to link the text to the units if you don't want to import a Unit Indexer into your map.
 
Last edited:
Status
Not open for further replies.
Back
Top