Created by Arty
Copied from Wayback Machine Project-Spark.org
On one of my levels my AI characters can enter a frozen state and to indicate when they would become active again I put a cooldown, or rather warmup bar on them. The bar is white and the colour bar drains over its duration. Its really easy to do this kind of thing in PS Here is code I used. This code is on the character affected by frozen status.
Two goblins frozen
1. when [duration timer][FrozenDuration] 2. when do [highlight][white] 3. when do [show meter][at position][position][+][GoblinHitBarOffset][timer ratio remaining][max][white][scale][0.5] 4. when [countdown timer][FrozenDuration] do [whatever]
Line 1. the FrozenDuration is a parameter defining how long the character should be frozen in seconds.
Line 2. Just puts a white border around char so player can see it is frozen.
Line 3. This puts the cooldown bar above the goblins head. GoblinHitBarOffset is a vector variable I defined because I wanted explicit control where it displayed above the head of char. See below how I set this.
Rather than using [position][+][GoblinHitBarOffset] you could just use [above] which does the same thing. I went to these lengths because I am displaying more than one thing above the characters head.
the [show meter] is using a few parameters Ill run through these.
- [at position] this is defining a position in game where the bar will be displayed. [position] is usually defined as at the feet of character props, for other props types it may vary. So to get it above the head of char I add my GoblinHitBarOffset vector variable which was defined like this.
when do [GoblinHitBarOffset]=[up][multiplied by][(][height][+][0.15][)]
- This too probably needs a little explanation, it includes vector arithmetic.
- [height] is the height of the character/prop, the 0.15 is the distance above char I want to display at.
- [up] is a special vector variable the indicates up direction for the character/prop. It always has a length of one.
- I want my hitbar offset to be ‘up’ the required height from the [position], at the feet, of the character. So I multiply the up vector by the required height, this will return a vector that when added to the character position will give position above the characters head.
- [timer ratio remaining] this is one of timer specific tiles found in output folder when in scope of timer. It returns a value 1 to 0, it has value of 1 at start and reduces to 0 when time runs out. Setting this and using a [max] value of  the bar will be full at start of timer and will drain over time.
- If you are interested in a bar that fills up over time then use [timer ratio complete] this starts a 0 and increases to 1 when the timer is finished.
- [white] is setting the bars colour to white, you guessed right?
- [scale][0.5] is making the bar half the size of its default setting.
if you want the bar to display as part of player screen UI then do not use [position at] but [on screen at] to define where to display the bar.