- Home /
The question is answered, right answer was accepted
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.
there are multiple ways to answer your problem, triggers, in game integers, etc. But we need more explination, like an example script or how exactly you grid works. please post more info and we will help you as soon as we can,
Answer by Eric5h5 · Jul 30, 2013 at 10:03 PM
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.
Thank you for this! I know I'm pretty late at responding but this definitely helped me out with my project at the time. Thank you!
Follow this Question
Related Questions
Player Going through colliders 1 Answer
Orbit player around center point 1 Answer
Implement moveSpeed to this object script? 1 Answer
Rigid body child Player movement 0 Answers
Making player move in an arc 0 Answers