C
C#2y ago
Zagan

❔ Code stops after a bit

I'm trying to make 3d game in unity and i made dice check zone when i roll the dice it shows what i get, but after a bit it will stop showing what i roll
19 Replies
Buddy
Buddy2y ago
$details
MODiX
MODiX2y ago
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
Buddy
Buddy2y ago
Please be more specific in what you need help with - Take a reference of what is mentioned above
Zagan
ZaganOP2y ago
give me a min or 2
Zagan
ZaganOP2y ago
and when i roll it agian ir just shows 0
Zagan
ZaganOP2y ago
heres the codes
hiyosilver
hiyosilver2y ago
Did you check if it ever gets to your switch statement? Comparing floats directly like this is unlikely to work. I'm assuming you mean to test if the die has come to rest completely, i.e. velocity is 0 in all directions. I'm not sure that is ever going to be the case after the initial state due to floating point imprecision.
hiyosilver
hiyosilver2y ago
Also the gif you posted seems to show that the very first roll is already returning the wrong number.
Zagan
ZaganOP2y ago
in the gif it scanned that i landed on 5 but the dice was still rolling
hiyosilver
hiyosilver2y ago
I also don't quite get why you do a <= check. If my assumption that you are checking if the die has stopped moving is correct.
Zagan
ZaganOP2y ago
correct i changed it to ==
hiyosilver
hiyosilver2y ago
Still though, did you read my previous posts? That will probably not work You can't directly compare floats with == and expect meaningful, consistent results.
Zagan
ZaganOP2y ago
so i do it with Mathf.Approximately?
hiyosilver
hiyosilver2y ago
That's the first thing I would suggest.
Zagan
ZaganOP2y ago
it worked, thanks alot!
hiyosilver
hiyosilver2y ago
Oh, nice.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server