To show damage overhead of player or entity.
Installation
To install just drop FloatingDamageIndicator on entity or player template. In case of entity you would need to adjust widget config to set Visibility from Remote Only to Everyone. Remote Only is enabled by default, because player likely does not need to see damage to them additionally.
Features
Attaching to OnDamage
By default package would listen in OnDamage call and use received damage (as well as causer) to display it as a floating number. You can control whether this is enabled or not using listenToDamage
property on FloatingDamage script.
Several Damages
- Each next item appears at a different position and then they float away at a different angles. Even if items are not displayed at the same time, angle change applies to each new item, until number reaches 10 or 5 seconds since last added item passed (when angle for new items would be dropped back to starting point).
- This still has couple of quirks needed to work out - it seems like new items woudl reset animations on old ones, which might be hard to avoid since it is Gameface bug.
Show Only to Damage Causer
FloatingDamage
script has onlyToCauser
property, which you can turn on in order to display damage only on the client of a player, who dealt the damage.
UI Customizations
Currently font and color could be customized with properties for all of displayed damages or using custom call for every one differently.
-
font
property simply defines font for all entries, pick any value from list of fonts: Using Fonts in Crayta | Crayta Developer Area. Take a part from there, which is before .ttf in font file name. For example for “Ewert-Regular.ttf” that would be “Ewert-Regular” -
defaultDamageColor
defines color for damage entries when amount is positive -
defaultHealColor
defines color for damage entries when amount is negative (i.e. healing)
Properties for color accept any CSS compatible strings that represent color.
Examples: “red” for simply red color. “rgba(200, 0, 0, 1)” for dark red. “#aa00bb” for some purpleish color.
If you want custom color or font for every item based on some game specific logic, like posion damage is green, electric blue, etc - you will firstly need to disable “listenToDamage” property. Then you need to call ShowFloatingDamage
method from FloatingDamage
script on the player or entity you installed template on.
Example call:
player:SendToScripts("ShowFloatingDamage", amount, causer, { color = "blue", font = "Eater-Regular"})
-
amount
is a number - how much damage happened -
causer
is who caused damage - only used whenonlyToCauser
is set to true -
color
is any CSS compatible string that represent color -
font
is a name of font, you can pick any value from list of fonts: Using Fonts in Crayta | Crayta Developer Area. Take a part from there, which is before .ttf in font file name. For example for “Ewert-Regular.ttf” that would be “Ewert-Regular”. There is no need to pass fontname additionally, same value would be used for name as well.
Showing Sign
By default in front of usual positive damage, indicator would add minus sign, so that it would be clear that player lost some health. Same goes for negative damage (healing) - sign would be plus. If you do not want any sign shown - you can disable showSign
property on FloatingDamage
script - then only absolute value would be displayed.
Ignoring Zero
If by some reason in your game some damages are zero and you do not want to show them - just turn on property ignoreZero
.