Hi everyone, I am facing a problem with OnTriggerEnter.
Why does OnTriggerEnter work at start, but after it has runned as it should and you change variables for the conditions, it doesn’t work? The methods that sets/changes the variables are the same for the start condition, and when event is triggered
I have debugged to check that the variables are actually changed to what we want, and that happens correctly. I am checking for collision detection for up to 4 conditions, four different objects colliding with the Collider. Basically you have four version of the code below, with four variable for each(activeCell2, activeBodyPart2, danceMove2Completed, currentDanceMove2 etc)
The variables are changed correctly, but they aren’t beeing checked in OnTriggerEnter, even though they should have.
Thank you and apologize for a little messy code.
void OnTriggerEnter (Collider cell)
{
if (cell.name == "cellID " + activeCell && this.name == activeBodyPart && !danceMoveCompleted) {
/**< if the active cell and our active bodypart collides, and dancemoves(so we can set currentMove to next dancemove when a dancemove is complted)
* not completed and a dance is not completed*/
cell.renderer.enabled = false; // after every collision, make cells invisible/dissapear
if (counter < currentDanceMove.Length - 1) {
drawFirstInstruction (currentDanceMove, counter);
}
if (counter < currentDanceMove.Length - 2) {
drawSecondInstruction (currentDanceMove, counter);
}
if (counter < currentDanceMove.Length - 3) {
drawThirdInstruction (currentDanceMove, counter);
}
Debug.Log (activeBodyPart + "collided with " + cell.name + " Counter: " + counter);
if (counter < currentDanceMove.Length - 1) { /**< increment counter by one while counter is less than second last element of the array*/
counter++;
}
if (activeCell == currentDanceMove [currentDanceMove.Length - 1]) { // if dance move is completed and dance is not completed
danceMoveCompleted = true;
checkMoves (numOfabp);
danceMoveCompleted = false;
danceMoveCompleted = true;
} // end if
activeCell = currentDanceMove [counter]; // active cell is set to the incrementing counter variable in currentDanceMove array for every collision
} // end first if