❔ 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
$details
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)
Please be more specific in what you need help with - Take a reference of what is mentioned above
give me a min or 2
and when i roll it agian ir just shows 0
heres the codes
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.
Also the gif you posted seems to show that the very first roll is already returning the wrong number.
in the gif it scanned that i landed on 5 but the dice was still rolling
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.correct
i changed it to ==
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.so i do it with Mathf.Approximately?
That's the first thing I would suggest.
it worked, thanks alot!
Oh, nice.
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.