Turn Based RPG Combat, Sorting Turns

Each character has a script and within the script a “speed” variable.

I have an empty GameObject with a script that will handle all the combat mechanics. This script accesses the speed value of every character. It also has these values in an array.

How do I script to have the Assign the turns based on speed? For example, 100speedChar goes before 70speedChar who goes before 50speedChar etc.

Thanks.

Flip the speeds, so that lower is better, with, say, 100/spd. That gives your speed 100 a 1 and speed 50 a 2. Call that the “ActionDelay.”

Start everyone off at their ActionDelay. Each turn, lowest number acts, and add their actionDelay:

speed100   speed50  speed70
    1         2       1.43   #1 acts, goes to 2

speed100   speed50  speed70
    2         2       1.43   #3 acts, goes to 1.43+1.43

speed100   speed50  speed70
    2         2       2.86   #2 acts (special rule slower wins ties)

speed100   speed50  speed70
    2         4       2.86   #1 acts again, goes to 3