Search Unity

[RELEASED] Deterministic Dice

Discussion in 'Assets and Asset Store' started by REDvsGREEN, Sep 12, 2019.

  1. REDvsGREEN

    REDvsGREEN

    Joined:
    Sep 8, 2019
    Posts:
    34
    Tested and supported for Unity version:
    2018.3
    2019.1
    2019.2

    WebGL - Documentation - Forum Thread

    Feature: Physics Based deterministic dice rolling.
    You decide what the dices will roll. Perfect for when you want to separate the code from the visuals. The dices rolls using the built in physics engine in Unity and will collide with your other objects/terrain.

    Feature: Normal Roll
    Roll the dices using Unity’s built in physics engine and each dice will give you the result during runtime!

    D6 with several different texture included.
    Includes Albedo and Normal map for both dots and numbers.

    Customizable Dices
    Includes original .FBX models with textures in original formats with all layers preserved in .XCF(GIMP) and .PSD(Photoshop) for an easy way to make your own customized dices.

    -----------------

    1.0
    First Release

    -----------------

    Please put any suggestions or questions in this thread.

    During the Beta phase i will run it with 50% discount.
     
    Last edited: Sep 12, 2019
  2. REDvsGREEN

    REDvsGREEN

    Joined:
    Sep 8, 2019
    Posts:
    34
    1.1 Release

    Fixed a bug where if the dice landed Y< 0 it had some issues finding the top roll.

    Added “Set Kinematic” which sets all other Rigidbodies to “set Kinematic” during the Simulation and unsets them afterwards.
     
  3. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    102
    Hello! I'm very interested in this but have a question. Does this work RPG type dice (d20, d12, etc) or only with 6 sided dice?
     
  4. REDvsGREEN

    REDvsGREEN

    Joined:
    Sep 8, 2019
    Posts:
    34
    Currently only with D6, but im planning to add full RPG dice set. Ill will keep you posted.

    EDIT: Also sorry for late reply, had to enable email notifications separatly for the forum threads.
     
    Last edited: Oct 22, 2019
  5. REDvsGREEN

    REDvsGREEN

    Joined:
    Sep 8, 2019
    Posts:
    34
    1.2

    Added a RPG looking Skull Dice that lights up when it lands. Can be changed to any color.

    SkullDiceGif.gif
     
  6. elwinxuxsg

    elwinxuxsg

    Joined:
    Jun 10, 2020
    Posts:
    1
    Hi, I'd like to ask if it is possible to make sure one side will be facing up when you do a deterministic roll. Currently, the way I've set it up is with 3 dices rolling within a small confined box using Colliders to simulate a Dice Cup). Therefore, this allows the dices to collide with each other as well with the wall and ground. Sometimes, one dice/die may lean on an angle against each other, some cases lean on an angle against the collider (invisible wall) as well.

    If you can offer some guidance, how can I resolve this issue? Thanks.
     
  7. REDvsGREEN

    REDvsGREEN

    Joined:
    Sep 8, 2019
    Posts:
    34
    Hi, Sorry for late reply, I did not get notification for the reply. The solution is quite simple, whenever a dice goes to sleep, activate it again and apply a small force downwards, this will make the dice tilt to one side.
     
  8. REDvsGREEN

    REDvsGREEN

    Joined:
    Sep 8, 2019
    Posts:
    34
    1.4 Update submitted to asset store:

    Added D8 and D20 dices.
    Added 25 new handpainted textures.

    Added 3 new Physics handling modes:
    Set Kinematic.
    Collide with Rigidbodies.
    Collide with Rigidbodies and Freeze.

    These physics handling modes are for when there are lot of rigidbodies in the scene the dices can collide with, provides better handling for those scenarios.

    Performance enchancements.
    Cleanup in code.

    Added another skulldice (does not work to roll deterministically.)
     
  9. REDvsGREEN

    REDvsGREEN

    Joined:
    Sep 8, 2019
    Posts:
    34
    1.5 Update submitted to asset store:

    Added D4, D10, D12 and D16
    Added 32 new handpainted textures.


    Added support for Unity 2D mode (Gravity is Z 9.81 ).
     
  10. xlilcasper

    xlilcasper

    Joined:
    May 18, 2016
    Posts:
    1
    Does this support custom dice faces? I would love to be able to set the sprite of the dice faces at runtime.
     
  11. REDvsGREEN

    REDvsGREEN

    Joined:
    Sep 8, 2019
    Posts:
    34
    Yes, you may change the texture/material at anytime, although please make sure the textures you are changing too have the numbers on the same position as the texture that is included.
     
  12. REDvsGREEN

    REDvsGREEN

    Joined:
    Sep 8, 2019
    Posts:
    34
    1.6 Released

    Added truncated D4.
    Increased size of numbers on regular D4.
    Exposed the direction Vector so you can choose the direction you want to throw the dices without making changes to the code.
    Added physics bounciness material for those who wants more bounciness.
    Cleaned some code.
     
  13. SecretAnorak

    SecretAnorak

    Joined:
    Mar 19, 2014
    Posts:
    177
    RPG Dice very rarely land correctly in deterministic mode. It looks like the colliders are not aligned properly:

    upload_2022-9-12_14-2-4.png
     
  14. REDvsGREEN

    REDvsGREEN

    Joined:
    Sep 8, 2019
    Posts:
    34
    This is because how the dice rolling works.

    1. We simulate the dice roll in physics in 1 frame, we then record the result of what the dices rolled.
    2. We restore the dices to the original position.
    3. We rotate the dice texture so that the number we want to roll replaces the actual roll.
    4. We playback the recorded simulation to the user with the rotated texture.

    On a D6 we can always rotate the texture 90 degrees which always makes it in sync with the physics collider. On the RPG dices this is not possible. So on the RPG dices there will be a discrepancy between how the physics collider lands and how the textures "land". However, the correct result is always at the top.

    How it looks(dices rolled 1):

    upload_2022-9-16_12-0-49.png

    Actual colliders:

    upload_2022-9-16_12-1-13.png

    I have not found a good way to rotate the textures to always fit the colliders without breaking the correct number sequence of the dices.

    With the D6 this is not an issue, it always syncs with the collider.
     
  15. NicBischoff

    NicBischoff

    Joined:
    Mar 19, 2014
    Posts:
    204
    Hi. The documentation doesn’t load and any chance of a December sale ? :)
     
  16. REDvsGREEN

    REDvsGREEN

    Joined:
    Sep 8, 2019
    Posts:
    34
    Hi, It works for me: https://www.redvsgreen.info/documentation/, does it not work for you?

    I don't control the discounts as I see it, I only select the max amount Unity can give and they choose when to give it or not to give it, at least that's my understanding. I hope they discounted it during Christmas..
     
  17. Kiziek

    Kiziek

    Joined:
    Jan 24, 2016
    Posts:
    2
    Hi, will deterministic mode work in VR?
    Something like OnHandReleased action will trigger Deterministic Roll.
     
  18. REDvsGREEN

    REDvsGREEN

    Joined:
    Sep 8, 2019
    Posts:
    34
    Hi,

    I don't see why not. The one thing to think about is that it has to simulate the entire dice roll sequence in 1 frame, this could lead to an fps spike depending on what hardware you run. But IMO most VR runs on pretty good hardware so it might not be an issue.