Skip to main content
added 9 characters in body
Source Link

the problem with your "for" code , that I think you placed inside the Update(), is that it get executed in one update cicle. In Unity you must think the Update as a 'frame' execution. Plus, that for seems useles. Where do you use the "i" variable?

So you must do something like this into the Update(), (I missed the starting and end management)

//small dist is a float value greater of 0 but not to big that you must initialize in the //Start()
if ((transform.position - spaces[currentPosition+i].position).magnitude < smalDist)
{
 // I reached next element 
 
 if (i==diceResult){
   //reached destination
   // STOp The movement 
 }
 i++;
 transform.position = Vector3.MoveTowards(transform.position,
    spaces[currentPosition+i].transform.position,Time.deltaTime / smooth );
}

the problem with your "for" code , that I think you placed inside the Update(), is that it get executed in one update cicle. In Unity you must think the Update as a 'frame' execution. Plus, that for seems useles. Where do you use the "i" variable?

So you must do something like this into the Update(), (I missed the starting and end management)

//small dist is a float value greater of 0 but not to big that you must initialize in the //Start()
if ((transform.position - spaces[currentPosition+i]).magnitude < smalDist)
{
 // I reached next element 
 
 if (i==diceResult){
   //reached destination
   // STOp The movement 
 }
 i++;
 transform.position = Vector3.MoveTowards(transform.position,
    spaces[currentPosition+i].transform.position,Time.deltaTime / smooth );
}

the problem with your "for" code , that I think you placed inside the Update(), is that it get executed in one update cicle. In Unity you must think the Update as a 'frame' execution. Plus, that for seems useles. Where do you use the "i" variable?

So you must do something like this into the Update(), (I missed the starting and end management)

//small dist is a float value greater of 0 but not to big that you must initialize in the //Start()
if ((transform.position - spaces[currentPosition+i].position).magnitude < smalDist)
{
 // I reached next element 
 
 if (i==diceResult){
   //reached destination
   // STOp The movement 
 }
 i++;
 transform.position = Vector3.MoveTowards(transform.position,
    spaces[currentPosition+i].transform.position,Time.deltaTime / smooth );
}
Source Link

the problem with your "for" code , that I think you placed inside the Update(), is that it get executed in one update cicle. In Unity you must think the Update as a 'frame' execution. Plus, that for seems useles. Where do you use the "i" variable?

So you must do something like this into the Update(), (I missed the starting and end management)

//small dist is a float value greater of 0 but not to big that you must initialize in the //Start()
if ((transform.position - spaces[currentPosition+i]).magnitude < smalDist)
{
 // I reached next element 
 
 if (i==diceResult){
   //reached destination
   // STOp The movement 
 }
 i++;
 transform.position = Vector3.MoveTowards(transform.position,
    spaces[currentPosition+i].transform.position,Time.deltaTime / smooth );
}