Creating Floating Combat Text For My FPS in Unity — Part 04

Chris Hilton
3 min readSep 28, 2023

Objective: Part 04 of setting up floating combat text in Unity will look at making scaling adjustments, including critical hits.

Moving on from the previous article where we looked at moving the text upwards using an AnimationCurve, we are now going to look at changing the scale using the exact same approach.

Previous code:

Adding a Changing Scale

Let’s add some additional code:

First, let’s add the new AnimationCurve public variable animScale and jump over to the Inspector so we can make an adjustment to the curve:

Now for the fun choice, would we like the scale to get larger over time, or vice versa? Let’s take a look at both:

Scale — Larger to Smaller:

Scale — Smaller to Larger:

Play around with custom AnimationCurves and create a custom X, Y graph to create some really unique visuals!

Creating a Critical Hit Visual

If you have played any games that have had floating combat text incorporated, you would probably have seen when a critical hit occurs, that the scaling on the text is much larger to help make this stand out.

Let’s make some changes and have a look:

We are just going to add 2 lines here, the first is a _critHitModifier and the second is simply multiplying this variable to the scale.

In terms of performance, it is more efficient to do calculations using multiplication rather than division.

Notice the emphasis on the curve to make that text appear larger for a brief period, before coming back.

Now all we would need to do is add some coding logic to determine whether a critical hit has occurred or not and whether it should use the _critHitModifier.

Part 07 of this series will look at building functionality for the ‘Critical Hit Modifier’.