#```Lua

1 messages · Page 1 of 1 (latest)

thorn totem
#

I looked at all this, and figured that combining questionable physics with math.random() really didn't improve over the included RNG alone. I use ```lua
function tryObjectRandomize(obj, pColor)
if string.sub(obj.getName(), 1, 3) == "Die" then -- a named Die xxx
local sides = #obj.getRotationValues()
obj.setRotationValue(math.random(sides))
-- put code dependent on the rotation value here e. g.
-- printToAll(pColor .. " rolled a " .. obj.getRotationValue() .. " with a " .. obj.getName())
return false
end
return true
end

#

The above completely avoids the need to wait for the dice to settle.

wide zinc
#

you'd need to make a random distribution quaternion, and then translate that into a Vector3, for the angle of the angular velocity

#

however, you still get the gimbal lock issue