Closed marvink closed 1 year ago
Hey @marvink sorry for the late reply. I never saw the notification in my email.
So, the colliderFaceMap
is used to determine which face of the die is pointing up. Once the die has settled, I use ray casting to draw a ray from the center point of the die straight up. This does not return the die number though, it returns the 3d mesh face id number. In the dice model file there is an object called colliderFaceMap
that associates the 3d mesh faces to die face values
"colliderFaceMap": {
"d4": {
"1": 1,
"3": 2,
"0": 3,
"2": 4
},
"d6": {
"0": 1,
"6": 1,
"3": 2,
"9": 2,
"5": 3,
"11": 3,
"2": 4,
"8": 4,
"1": 5,
"7": 5,
"4": 6,
"10": 6
},
...
}
This might be more info than you wanted, but that's the setup. If you're receiving the error of 'no value found' then there's a number of things that might have gone wrong. Based on the face value of -1
I'm guessing that the collider is not found when the raycasting was done. Are you using the default dice set, one of the dice-theme sets I built or are you trying to use a new custom set?
You also mention that you don't see a die rolling and then you get the error. Somehow you may be triggering a roll but the system never creates the dice. Not sure how that would happen unless a die was removed and then rerolled after removal.
@herbig, I took a look at your project. I was not able to recreate the issue at the moment, but my best guess at the error appearing is this. You're using rather large dice in a tight dice box. If the throwForce is high, sometimes the dice will penetrate through the dice box walls and fall into infinity. At that point the collider is gone (purged) and unavailable for the final computation. Typically the solution for this is to increase the physics engine's step frequency but that value is not exposed in the module. The throwForce doesn't seem too high currently. Perhaps try scaling your dice down a bit?
I'll keep looking into it to see if I can recreate the issue. If nothing else I should try to catch this error and handle it properly so it doesn't kill the roller.
I'll keep looking into it to see if I can recreate the issue. If nothing else I should try to catch this error and handle it properly so it doesn't kill the roller.
Actually in testing it last night I realized I was calling show()
/ hide()
when rolling e.g. diceBox.show().roll()
then diceBox.hide().clear()
after a timer to reset.
When I removed the show / hide calls, which wasn't really necessary, the issue went away. Would that have been causing it?
I am facing an issue in some situations, i cannot say what the difference between these rolls is.
I don't see a dice rolling and after a while i get the following issue.
What does this mean?