Greetings Everyone
Hope everything is going well with all of you d(^^)
Here’s my problem:
I’m doing a monopoly game and I have 2 dices that are giving value (1 - 12).
Everything is working, even the turns, but the problem is, if the value of the dices is equal to the previous one, it stops working =/
ex:
the first turn this where the values
dice1 = 3
dice2 = 5
The dice gives a value to the GameController, and in the Script GameController it just sum’s the two dices value and gives order to the Player to move.
now if you role the dices on the next turn and the dices value are the same as the previous turn, the game just doesn’t do anything, it stops =(
What can i do to correct this?
here’s the code one the dices (i have 2 dices, so i created 2 scripts)
dice1:
public var faceValue = 0; // guardará o numero da face mostrado do dado 1
private var dieValueComponent1; // cache do 1º dieValueComponent
private var tempo= 0.0; //tempo de inicio
private var tempoTotal = 1.5; // tempo total
// estas variáveis só servem para irem procurar um valor ao GameController que irá dar a "ordem" para iniciarem a contagem;
private var ijogo : GameObject;
private var jogo;
function start ()
{
dieGameObject = GameObject.Find("Dado"); // aqui será guardado o 1º dado como gameobject
dieValueComponent = dieGameObject.GetComponent("DieValue");//aqui será chamado o script DieValue
ijogo = GameObject.Find("MasterController");
jogo = ijogo.GetComponent("GameController");
//Debug.Log(jogo);
}
//aqui será chamado quando os colidders se encontrarem pela primeira vez
function OnTriggerEnter( other : Collider ) {
//ter a certeza que o totalTimeTriggered é zero
tempo = 0.0;
//Debug.Log(faceValue);
//Debug.Log(faceValue + "entered" + other.name);
}
//é chamado quando os colliders estão em contacto
function OnTriggerStay(other:Collider){
ijogo = GameObject.Find("MasterController");
jogo = ijogo.GetComponent("GameController");
if(jogo.pJogar == true)
{//add to total time
tempo += Time.deltaTime;
//Debug.Log(tempo);
if(tempo > tempoTotal) // Dado está parado
{
dieGameObject = GameObject.Find("Dado");
dieValueComponent = dieGameObject.GetComponent("DieValue");
dieValueComponent.currentValue = faceValue;
}
}
}
//called when colliders leaves
function OnTriggerExist (other:Collider)
{
dieGameObject = GameObject.Find("Dado");
dieValueComponent = dieGameObject.GetComponent("DieValue");
//limpar o total time
totalTimerTriggered = 0.0;
dieValueComponent.currentValue = 0;
}
the same code is apply for the second dice, with a small change.
I thank you all in advance for helping me on this.
Have a rest of a good day and thank you again for helping me =)
p.s: sorry for my English, I’m Portuguese =P