Implementing Speed

Aaron Grincewicz
2 min readMay 31, 2021

--

Finally Making Use of the Unit’s ‘Speed’ Stat

I set up my Battle System’s units with a few basic stats. One of them being ‘Speed’. I wasn’t too sure in which way I would use it at first, but today I decided to finally implement it.

In my projects GameManager class I created a method that uses my DieRoll struct to determine which player goes first based on their starting Unit’s speed stat.

Based on the results of the Die Roll, the Battle State will change. The Unit with the higher speed stat gets the difference between their speed and the enemy speed added to the result, giving them a higher chance of going first.

You’ll also notice I have a variable for Consecutive Turns. This comes into play at the end of a turn. The Unit with the highest speed gets to roll and see if they can have another turn. If they go again, the consecutive turn increments. Each unit cannot have more than one extra turn.

Eventually I’ll be expanding this whole implementation to incorporate more than two units. For now, it makes use of the Speed stat, and the items I created to buff it.

--

--