- Home /
Question by
techniquea2z · Oct 19, 2020 at 09:34 AM ·
grid based game
How can I slow down cell selection
Adding the keyboard input code:
IEnumerator UserCellSelection(int lastCellIndex) {
int cellIndex;
float waitTime = 20000000f;
float vertAxis = Input.GetAxis("Vertical");
float horiAxis = Input.GetAxis("Horizontal");
if (vertAxis != 0) {
if (!movingPlayer)
tgs.ClearAll();
int newRow;
if (vertAxis > 0) {
newRow = SelectedCell.row + 1;
} else {
newRow = SelectedCell.row - 1;
}
if (newRow < 0)
newRow = 0;
cellIndex = tgs.CellGetIndex(newRow, SelectedCell.column);
if (horiAxis != 0) {
if (!movingPlayer)
tgs.ClearAll();
int newCol;
if (horiAxis > 0) {
newCol = SelectedCell.column + 1;
} else {
newCol = SelectedCell.column - 1;
}
if (newCol < 0) {
newCol = 0;
}
cellIndex = tgs.CellGetIndex(SelectedCell.row, newCol);
lastCellIndex = SelectedCell.index;
}
}
I call this method:
new void Update()
{
base.Update();
// Only check for user input during Player Phase
if (gameManager.currentPhase == "Player") {
int lastCellIndex = SelectedCell.index;
StartCoroutine("UserCellSelection", lastCellIndex);
if(actionSelect) // Draw attack range
DrawPlayerAttackRange();
if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.X)) {
UndoPlayerSelect();
UndoPlayerMove();
}
I tried using WaitForSecondsRealtime, no dice. I wrote this on an older laptop, so the slow FPS was making selection more manageable. I don't want to intentionally limit my FPS, looking for a solution to move one square every 10 seconds, somewhere around there.
I am using Terrain Grid System plugin for the grid. I've basically tied to Horizontal & Vertical Axes to rows and columns in the grid.
Comment
Your answer
Follow this Question
Related Questions
Problem with raycast detection? 1 Answer
How to Shuffle Prefab Clones on a Grid 0 Answers
creating and manipulating a grid efficiently 1 Answer
How do I set up a grid from a slanted perspective? 0 Answers