jeudi 9 septembre 2021

Problems with Unity Random Function

Good evening, I was working on a graphic adventure and I want to make a random function with a 4 digit code, turns out that as I am a very novice programmer, I crashed with an inconvenient

private void CheckResults()
{
    if (codeSequence = RandomCode.RanCode.ToString())
        {
    SoundManager.PlaySound("nice");
    }

else
{
    SoundManager.PlaySound("wrong");
}   

"RandomCode.RanCode" is a int void, and adding "ToString" will shot an error saying

"RanCode is a method which is not valid in the given context"

This is the RandomCode void:

 public void RanCode()
{
    Code = Random.Range(1111, 9999);
}

If anyone out there has any ideas or solves, I will be eternally grateful




Aucun commentaire:

Enregistrer un commentaire