How to track the amount of units a player has moved?

Hey guys,

So I’m making a turn based RPG and what I’m trying to do is start a battle after a certain number of steps have been taken.

I have a grid script set up to where the player will move 1 unity unit at a time across the grid. So what I would like is to have, after between 5 - 10 steps, a battle will take place.

I’m just wanting to know if there’s a way to track how many units the player has moved.
If not then any suggestion would be much appreciated!

Thanks.

Have a “unitsMoved” variable for the player, and every time the player moves, do “unitsMoved++”. Also have a “battleCount” variable, which is set like “battleCount = 5+Random.Range(0, 6)”, and compare that to unitsMoved every turn, so “if (unitsMoved == battleCount) DoBattle();”. Then reset unitsMoved to 0 and reset battleCount after the battle.