So i’ve been stuck for several hours trying to figure out how I can make the combination code to be corrected or incorrect. For some reason I only see “Wrong combination Code” and also my gameObject currentCombination int, change from its original number to 0. Any Ideas how might I fix this to correctly work? There is a lot of commenting out in here, just been testing out the possibilities:
So this is where the combination will be declared on the keypad
// This is for the KeyPad Buttons Area
foreach(Keybutton button in buttons)
{
if(Input.GetMouseButtonDown(0)) {
if (button.gameObject.Equals(hit.collider.gameObject))
{
hit.transform.renderer.material.color = Color.red;
button.ButtonWasClicked();
break;
}
}
}
}
}
This is where the functions of the combination work and process
public class Keybutton
{
public GameObject gameObject;
//public int Numberbutton;
private int Combination = 1234;
public int currentCombination;
private int buttonClickProgress;
public void ButtonWasClicked (){
currentCombination = 0;
//buttonClickProgress;
if(buttonClickProgress < 2){
currentCombination *= 1;
}
else{
if(currentCombination == Combination){
Debug.Log("You Opened the Combination lock!");
}
else{
Debug.Log("Wrong Combination Code, reseting...");
gameObject.SetActive(false);
}
}
}
}
So should I just make each gameObject button equal a number??
– GhostDreYou didn't tell your number buttons are GameObjects. You should definately give more detail about what the situation here is and what you want to accomplish.
– NoseKillsSorry I didnt cover that, but I was just about to comment on your answer about, these buttons are gameObjects you click on. Each one is assigned a number 0-9. Do you know how else this can be done?
– GhostDreShould I change int Combination and int currentCombination to strings?
– GhostDre