How to check the waypoint position of a character?
Hi! I have a character object in a waypoint system. I want to move it to another waypoint system using a dice. The thing is that when the object moves to the other waypoint system, it moves one waypoint more than what the dice indicates (if the player rolls the dice and needs to move 4 waypoints, he moves 5 because it doesn't count the initial waypoint of the intersection). To 'solve' this I just substract 1 value of dice result:
GameController.diceValue = GameController.diceValue - 1;
This works except when the dice rolls 1. if it does, the character doesn't move (1-1 = 0). I thought about not applying it a -1 and instead check if the object is in the correct waypoint and stop its advance by reducing the value of the dice to 0. In this way:
if (GameController.diceValue == 1)
{
Debug.Log("the dice rolls 1");
if (transform.position == selectedRoute[0].transform.position)
{
Debug.Log("it stops in the waypoint");
GameController.diceValue = 0;
}
}
else
{
GameController.diceValue = GameController.diceValue - 1;
}
But it doesn't work. In the console there is no error. It is just the conditional "transform.position == selectedRoute[0].transform.position" that doesn't apply. The debug.log doesn't appear in the console.
Am I not checking it properly?