#quiz game freeze
1 messages · Page 1 of 1 (latest)
okay okay
can you show me this window?
how?
screenshot it
oh wait
on windows, Win + Shift + S will let you clip part of your screen and then paste it
quiz game freeze
wait it breaks now
hit Continue to let the editor resume
i'll press the pause?
then make the game freeze and pause in VS
okay i did it
you may need to switch the thread you're viewing if it paused on the wrong one again
i see
wait, can you show me how you attached to unity?
okay, so that should be right
make sure that the editor is in Debug Mode, run the game, and Attach to Unity in VS
don't make the game freeze yet
that bug icon should be green
oh, is it yellow?
its blue now
i'm red-green colorblind lol
wait i'll try to press the buttons again
oh wait
i didnt pressed play
okay its still blu
once you enter play mode, try pausing in VS
okay i'll pause now
see if it actually has a main thread this time
its still frame not i module
yeah i'll just screenshot it
hm, that's not very useful
tell you what -- i'm going to go set this up correctly on my PC and try debugging myself
what version of unity is this?
2022.2.5f1
gotcha
is there a better way to do the not giving the prev asnwers?
if that's the problem i guess that's what should i replace
I guess I'd just make a list of all things you haven't asked yet
i mean question
and then remove things from the list as you ask them
uhhh sure
i'm really curious what the problem is with the debugger tho
it's very useful for tracking down things that make the editor freeze/crash/instantly close
ohhh i see
yeah its been bugging me in the last 2 - 3 days with this error
but it works when i remove the popup of the panel
should i try it on my phone and see if it works?
oh, that's a useful thing to know
so what do you change, exactly?
ah, this looks familiar
wait i'll try it again just to be sure
nope still freezes
so i guess its the retaining the question thingy?
so I wrote some code that freezes the game
if I execute that and then hit the pause button, it does show me the right stuff
yeah mine doesnt
normally, when you break, you catch the game while it's just sitting around
waiting for the next frame
that explains what you're seeing, at least...although it is weird that nothing changes when the game is frozen
yeah
can we just focus on the checking the prev question? on how that does the infinite loop?
i think that is the cause of the infinite loop
you could rule it out by removing the check
normally, I'd be trying a debugger after this kind of thing fails to find the problem, but I guess we're doing it backwards today 😛
alright i'll try it
oh yeah, one other thing you might try with debugging
AHHAHAHA welp my code editor is not funcitoning properly
if you right click on a line and add a breakpoint, then attach the debugger, it will auto-break when it hits that line
so, if I were using the debugger, I'd put a breakpoint on the function that checks for a duplicate
and see if it runs over and over
i see
btw
yeah it works perfectly without the checker of the prev question
so wdyt?
okay, so that's the prime suspect
the question, though, is why it's getting stuck like this
it just stops you from getting the same one twice
even if there are only 5 choices, the odds of it getting stuck for a long time are insanely low
yes
should i add tostring ?
just like this
ansHandler = shapes[randomButtonShape].ToString();
does this help?
because the ansHandler is a string to begin with
nope, that shouldn't be relevant
yeah i just came up with that loop
if you want to catch it in action, maybe add a static int that counts how many times you've checked the answer
throw an exception if it gets over, say, 25
but if you have a better loop process that would be really helpful for my thesis
and log the values at each step
you should see some kind of interesting pattern
like it picking the same string every time
yeah i tried that
like a string to check if what is being added to the string
and it still freezes before throwing back
did you add a hard limit for the number of tries?
like
public static int tries = 0;
[...]
void CheckAnswer(string str) {
++tries;
Debug.Log(str);
if (tries >= 25)
throw new Exception();
}
show me what you wrote
if(newAns == prevAnswer)
{
tries++;
if (tries == 25)
{
checkertries.text = tries.ToString();
ansIfGo = true;
questionRandom();
}
checkertries.text = tries.ToString();
ansIfGo = false;
questionRandom();
}
something like this
didnt add the throw
how do you add that again to a method?
throw new Exception()
also, don't make this conditional
put this right at the start of the checker method
so that, no matter what, it can't run more than 25 times
ah, no, you don't add anything to the declaration
this isn't Java
aight i'm in
i'll try this
wait
okay
the shit didnt change
this means the error occured
and i have the error on the code/unity
editor didnt freeze
did you log the string it was trying each time?
yes
oh shit
i added the throw before the count
lmao
wait up
i'll run it again
alright now i thrown it after the counter
but its still 0
void prevAnsCheck(string newAns)
{
if (newAns == prevAnswer)
{
tries++;
if (tries == 25)
{
checkertries.text = tries.ToString();
throw new System.Exception();
ansIfGo = true;
questionRandom();
}
checkertries.text = tries.ToString();
ansIfGo = false;
questionRandom();
}
else
{
checkertries.text = tries.ToString();
ansIfGo = true;
}
}
heres the code
"it's still zero?"
yes
the tries counter
ah, you added some text for it
this
or freezes
move this out to the very top of the function
if (tries == 25)
{
checkertries.text = tries.ToString();
throw new System.Exception();
}
okay okay
and increment tries up top, too
so that, no matter what, it does ++tries every time you call the function
okay i'll try it
wait
wtf
it doesnt do the freezing shit
wait
the loop is working
and it just loops for 1 time
i had a debug there to print the tries
oh
i removed the call
fuck
wait
there we go it freezes again
but the throw doesnt make it stop or resets
basically the part of tries == 25 is not being used
it just freezes
this is making me think it's happening somewhere else
You might need to go back to the debugger and add a breakpoint somewhere in the answer picking function
and then step through it to see where it’s getting stuck
damn
Adding a breakpoint should make it actually find your code
do you have a better way to do this looping thing for the question?
if its not a ahassle to you i'd be glad if you have a different method
i just fixed it
i removed the function
and just added the loop inside itself
something like this
void questionRandom()
{
randomNumber = Random.Range(0, 3);
randomButtonShape = Random.Range(0, maxRangeShape);
ansHandler = shapes[randomButtonShape];
if(ansHandler == prevAnswer)
{
Debug.Log(shapes[randomButtonShape]);
questionRandom();
}else if (ansHandler != prevAnswer)
{
Debug.Log(shapes[randomButtonShape]);
questionNumber = questionNumber + 1;
currentNum.text = questionNumber.ToString();
randomBtns();
}
}
thank you