Logic says, if the first one is true, it executes the code and doesn’t move on to the else statement. That’s not true in my case.
I have this code:
public void CheckPuzzle()
{
for(int i = 1; i <= 3; i++)
{
currentPuzzlePiece = PlayerPrefs.GetInt("puzzle piece number");
nextPuzzlePiece = i + 1;
if(currentPuzzlePiece == nextPuzzlePiece - 1)
{
// Correct
Debug.Log("Second IF: Correct");
} else
{
// Incorrect
Debug.Log("Second IF: Incorrect");
}
}
}
Which is triggered on a collider:
private void OnTriggerEnter(Collider other)
{
PlayerPrefs.SetInt("puzzle piece number", puzzlePieceNumber);
firstPuzzle.CheckPuzzle();
}
And I am getting both in console:
I’m also not sure if my game logic is right.
I’m trying to make it so you have to step on these in the correct order, if you fail, it resets the player to try again:
How I’m “attempting” to do it now, is when you step on one, it saves what you stepped on with PlayerPrefs and compares that to the correct square. If it’s wrong, you have to try again. If it’s right, you have to guess the next square.
Note: each block has a Puzzle Piece Number assigned in the inspector. Blue is 1, Green is 2, Red is 3.
Help is greatly appreciated. Thank You.