BoardGame Player won't stop moving on the second lap

Greetings.
I’m following tutorials from Unity, which I really like.
Last one I found was a Simple Board Game from here

(DMA 157B – Gaming 2 – Winter 2011).

Now, there’s a problem:

2.After one lap is done and Transform returns player to the “1” position, it continues to move without rolling and won’t stop.

Help, please. I want this small game done :slight_smile:
Thanks in advance.

I was thinking the whole over and made up 2 solutions (probable ones).
Here’s actual code:

public var dieName = "SixSidedDie";
public var allowedDistance = 0.5;
private var lastDieValue = 0;

private var target : Transform;
public var damping = 3.0;
private var dieValueComponent;
public var currentLocation = 1;
public var targetLocation = 1;


function Start() 
{
   dieGameObject = GameObject.Find(dieName);
   dieValueComponent = dieGameObject.GetComponent("DieValue");
   tileGameObject = GameObject.Find("tile" + currentLocation.ToString() + "target" );
   transform.position = tileGameObject.transform.position;
   transform.rotation = tileGameObject.transform.rotation;
}

function Update ()
{
   if (dieValueComponent.playStarted)
   {
      if (lastDieValue != dieValueComponent.currentValue && dieValueComponent.currentValue != 0 && dieValueComponent.turnBegun)
      {
         targetLocation += dieValueComponent.currentValue;
         currentLocation += 1;
         if (currentLocation > 16) currentLocation = 1;
         if (targetLocation > 16) targetLocaiton = 1;
         tileGameObject = GameObject.Find("tile" + currentLocation.ToString() + "target" );
         target = tileGameObject.transform;
         dieValueComponent.turnEnded = true;
      }
      if (lastDieValue != 0)
      {
         dist = Vector3.Distance(transform.position, target.position);
         if (dist > allowedDistance)
         {
            transform.position = Vector3.Lerp(transform.position, target.position, Time.deltaTime * damping);	
            transform.rotation = Quaternion.Slerp(transform.rotation, target.rotation, Time.deltaTime * damping);	
         }
         else if (currentLocation != targetLocation)
         {
            currentLocation += 1;
            if (currentLocation > 16) currentLocation = 1;
            tileGameObject = GameObject.Find("tile" + currentLocation.ToString() + "target" );
            target = tileGameObject.transform;
         }
      }
      lastDieValue = dieValueComponent.currentValue;
   }
}

So, my ideas are:

  1. Reset String parameter. Like (if currentLocation > 16) StringValue = 1.
  2. Create an array of just 16.
  3. Create alternative fake String implementing one more var (i), which is activated on trigger and sets location on the next lap:

Like
i - lap number (“16” x times trigger activated + starting location)
1st lap - starting location = 1;
2nd lap - 17;
3rd - 33…

and so on.

Any comments on these ideas?