- Home /
This question was
closed Aug 23, 2017 at 10:44 PM by
skifayat for the following reason:
I figured out it myself.
Question by
skifayat · Aug 15, 2017 at 03:14 PM ·
scripting problemtransformpositionvector3
how do i move ludo token to right side
I am using while loop to move player token forward. i want move player token to right after it reaches the last block of forward line.
my code for moving the token. (applied to player token)
// moveto default value is "f"
public Text moveto;
// function to move player token
void forward(int dice_number) {
int i = 0;
while (i < dice_number) {
if (moveto.text == "f")
{
Vector3 cpos = new Vector3(-5f, 0f, 0f);
token.transform.position += cpos;
}
else if (moveto.text == "r")
{
Vector3 cpos = new Vector3(0f, 0f, 5f);
token.transform.position += cpos;
}
else
{
text.text = "error";
}
i++;
}
}
// on btn click function
void move() {
int rand = UnityEngine.Random.Range(1, 7);
// text.text = rand +"";
forward(rand);
}
I have a code which change "moveto" value which is applied to last box but it only work's if player token stays on then last box.
public Text moveto;
private void OnTriggerEnter()
{
moveto.text = "r";
}
Comment