I am trying to have a token stop when it hits a certain tag, and the tags name is a number. There is a variable that holds the number that it will stop, which corresponds to the tag name.
If your confused right now, here is the script:
var playerposition = 0;
function OnTriggerEnter( stoper : Collider ){
if(stoper.gameObject.tag == playerposition){
move1 = false;
}
}
The part that I’m confused about is the .tag == playerposition.
A tag is a string, so you seem to be trying to compare a string with an integer. Your “playerposition” variable should also be a string.
–Eric
Ok, I probably should have said this before…
I have a dice, and when the dice is rolled, it takes THAT number, and adds it to the playerposition variable. So is there a way to take the number and convert it to a string?
I dont think this works. I placed in the code as:
playerposition.ToString();
and it did not work. Is there something wrong with the syntax, or is there a different way?
I’m not sure where you put that code. It should be something like
if (stoper.gameObject.tag == playerposition.ToString()) {
–Eric
Thank you!!! This works like a charm 