Workshop

Damage numbers Free
Install

Creates a billboard with any integer value. Every spawned number can have different life time, size, color (RGBA) and speed. For example you can create green numbers for healing effects or spawn bigger numbers if damage is very high.

[u]Attention[/u], this script uses global player script variable to get camera rotation. To use this you will need to create global player script variable as I did, or change this script a little.
To create global player script variable just add this line in Script:Start() in player script:
player=self
This will also let you easily access player script from any other script at any time.

How it works:


There are simply ten prefabs with sprite for each digit. Needed prefabs are loaded when damage number is created. Then each frame they are rotated to face camera (can't simply be billboards because each digit has different position, but should have the same Y rotation).

How to create damage number:


You need to load damage number, set it's position and call CreateDamageNumber() function like this:
local entity=Prefab:Load("Damage numbers/Damage number.pfb")
entity:SetPosition(x, y, z, true)
entity.script:CreateDamageNumber(value, lifeTime, size, color, speed)

You don't need to pass all of possible parameters to this function, they all have default values.
I think it's also a good idea to load each of ten digits prefabs at the start of the game and leave them hidden so new numbers will always be instanced from them.

CreateDamageNumber() parameters:

    [value - damage value. 0 by default
    [lifeTime - 4 seconds by default
    [size - size of each digit. 0.2 by default
    [color - Vec4 (RGBA). Red by default - Vec4(1,0,0,1). Range of each of 4 values is from 0 to 1, not to 255.
    [speed - Vec3 in global space. (0,0.01,0) by default.

Information