Recreating Genshin's Rigged Dice Roll in Unity (Deterministic Dice)

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ม.ค. 2025

ความคิดเห็น • 48

  • @ReForgeMode
    @ReForgeMode  ปีที่แล้ว +10

    Wanna watch this episode earlier? Head over to my Patreon page!
    www.patreon.com/posts/78779407
    This is really my biggest project so far in this channel. It took about two weeks to get it to work in Unity and another two for editing and publishing. I hope you guys enjoy it!

  • @Juslin7989
    @Juslin7989 ปีที่แล้ว +10

    Very nice video. GITCG server approved

    • @ReForgeMode
      @ReForgeMode  ปีที่แล้ว +3

      Haha. Thank you! 😄😄

  • @MountainisFullofDragons
    @MountainisFullofDragons 8 หลายเดือนก่อน +2

    thank you. this is literally what ive been searching. it took me over 3 hours to find your vid that solved the exact mechanic for dice that im looking for

    • @ReForgeMode
      @ReForgeMode  8 หลายเดือนก่อน +1

      Happy to help! I've always wanted to make videos like these! 😄😄

    • @MountainisFullofDragons
      @MountainisFullofDragons 8 หลายเดือนก่อน

      @@ReForgeMode how did you get the dice to appear from offscreen to on screen? Did you place dice above the main camera?

    • @ReForgeMode
      @ReForgeMode  8 หลายเดือนก่อน +1

      @@MountainisFullofDragons Right, so the Camera is looking directly at the "table" down below. Because the camera field of vision forms a cone, some dice may look to go offscreen as it falls down. I did share this project publicly on Github if you want to check out the full setup. Link is in the description.

    • @MountainisFullofDragons
      @MountainisFullofDragons 8 หลายเดือนก่อน

      @@ReForgeMode ah i see, thank you. i think im just gonna move my dice higher up, but everything else has been done the way i wanted it. The important part was rigging the dice for some scripted events I was attempting to do. thanks again man!

    • @ReForgeMode
      @ReForgeMode  8 หลายเดือนก่อน

      @@MountainisFullofDragons No problem! 😄😄

  • @yugiohk574
    @yugiohk574 ปีที่แล้ว +2

    I took another approach that for my game was easier (also didn't know about the physics simulation but anyway...)
    The dice is thrown with random forces and rotation, but I dont use any kind of physics detection of which face landed or something like that, instead I lerp between the current rotation to the desired face rotation very quickly, as in my game the dice just bounces of the walls in a high speed, you can barely notice that the dice sometimes rotates backwards and it works just fine haha

    • @ReForgeMode
      @ReForgeMode  ปีที่แล้ว +1

      Hmmm, very interesting! I wonder if there is some degree of uncertainty when the game lags a bit though... I will try to test it myself when I have the time.

  • @ngefy
    @ngefy ปีที่แล้ว +4

    Great video! Really useful information.

    • @ReForgeMode
      @ReForgeMode  ปีที่แล้ว +2

      Thank you! Glad I could help!

  • @Ferenc-Racz
    @Ferenc-Racz ปีที่แล้ว +1

    Finally a dev who really understand the game dev, not just know the framework. :) Subscribed now. :) Thank you for the video.

    • @ReForgeMode
      @ReForgeMode  ปีที่แล้ว

      Haha, thank you! 😄😄

  • @nancywinner
    @nancywinner ปีที่แล้ว +3

    Some artifacts (specifically the full set elementals) also guarantee dice rolls. I've gotten full hydro dice rolls with that & jade chamber.
    I always wondered how it guarentees a roll despite the actual roll looking random, so thanks!

    • @ReForgeMode
      @ReForgeMode  ปีที่แล้ว +1

      Oh yeah! I forgot the artifacts because I rarely played artifacts, haha 😄😄

  • @ArksideGames
    @ArksideGames หลายเดือนก่อน +1

    🤯🤯Incredible, Subbed

    • @ReForgeMode
      @ReForgeMode  หลายเดือนก่อน

      Thank you for the kind words!

  • @Nikinuito
    @Nikinuito ปีที่แล้ว +1

    Amazing tutorial, well explained, entertaining and easy to follow.

    • @ReForgeMode
      @ReForgeMode  ปีที่แล้ว

      Thank you so much 😄😄

  • @tianqigao869
    @tianqigao869 ปีที่แล้ว +2

    awesome tutorial! you are so smart!

  • @sirixb
    @sirixb ปีที่แล้ว +1

    Amaizing video thanks!

    • @ReForgeMode
      @ReForgeMode  ปีที่แล้ว

      Thank you! Glad I could help!

  • @ArielekGames
    @ArielekGames ปีที่แล้ว

    The new ECS physics in Unity are actually deterministic and you could use them for this case 😉
    Note: Just not cross platform deterministic, it will yield different results depending on the target platform thanks to inconsistent hardware float implementation (ex. two x64 computers will have identical results with the same setup, but they will be different from the same simulation on android, ios or even web).

    • @ReForgeMode
      @ReForgeMode  ปีที่แล้ว

      Oof, I haven't learned ECS yet 😂😂
      I am actually waiting for them to complete it first. Who knows when they'll remake it again hehe~
      But good to know for future projects

  • @sbu102
    @sbu102 9 หลายเดือนก่อน +1

    Great video, thanks

    • @ReForgeMode
      @ReForgeMode  9 หลายเดือนก่อน

      Glad you like it! 😄😄

  • @iiropeltonen
    @iiropeltonen ปีที่แล้ว +1

    Great technique!

  • @Digildon
    @Digildon 10 หลายเดือนก่อน +1

    Cool

  • @catpyjamas
    @catpyjamas 3 หลายเดือนก่อน

    My question is, how do you know when you have multiple dice? For instance, I have 3 dice. But then I have 4 dice. Four will be different, because they will bump into each other more. Does that mean I have to have separate sets of scriptable object recordings for each potential number of dice?

    • @ReForgeMode
      @ReForgeMode  3 หลายเดือนก่อน +1

      No, it doesn't matter how many dice you throw because it's always the same two dice throw simulation. If they do bounce, they will always bounce the second time.
      You will only need to adjust the Scriptable Object if you're using a different-sided dice.

  • @barangursoy5660
    @barangursoy5660 7 หลายเดือนก่อน

    I did the same logic for a 6 sided dice, but whenever in the rotation matrix there is a 270 degrees on X axis, it just gives a wrong rotation result and I don't get the result I want, is this related to gimbal lock, or am I doing something wrong? Thank you for your help and the video!

    • @barangursoy5660
      @barangursoy5660 7 หลายเดือนก่อน

      Normally, from 4 to 1 it should be (270, 0, 0) in (x,y,z) format right? But it doesn't work, when I tried (90,90,90) for no reason, it worked and I'm always getting 1 whenever the simulation result is 4, how is this working, I'm really confused, why 270,0,0 didn't work?

    • @ReForgeMode
      @ReForgeMode  7 หลายเดือนก่อน +1

      Hmmm... Assuming 1 is at the top, I think a rotation in X means you are rotating the dice upside down, so it's either 3, 1, 4, 6, depending on your dice layout.
      I'm not sure why it doesn't work, though. It should give the same result if you enter the value into the ScriptableObject. I think I would try to check the dice layout first, and then try to see if the rotation should be -180 < x < 180. So instead of 270, you can just use -90.

    • @barangursoy5660
      @barangursoy5660 7 หลายเดือนก่อน +1

      @@ReForgeMode Thank you for your response, -90 didn't work as well but I solved it, I'm writing this so if anyone else faces with the same problem, here is my not so well thought 😅solution: I removed the whole rotation matrix, my dice had 2 on the top as default, and rotation from 2 to all other faces were correct, I solved my problem by this logic: whenever a face other than 2 came, I first rotate them to 2 (default rotation of my dice) then rotate it again with only default rotation's rotation matrix to other numbers, it works perfectly, thank you so much for your quick response and your brilliant solution + video 🤗

    • @ReForgeMode
      @ReForgeMode  7 หลายเดือนก่อน +1

      @@barangursoy5660 Glad you figure it out! Let me know if you need any other help! 😄😄

  • @danielebassano7635
    @danielebassano7635 ปีที่แล้ว

    Hi, any ideas where can I find the from-to rotation matrix for a 10 sided dice?

    • @ReForgeMode
      @ReForgeMode  ปีที่แล้ว

      Well, I mostly write the six sided dice manually without any calculation. I just rotate the dice and find the rotation after for every face.

    • @danielebassano7635
      @danielebassano7635 ปีที่แล้ว +1

      @@ReForgeMode Thank you very much, I think I'll do the same.

    • @ReForgeMode
      @ReForgeMode  ปีที่แล้ว

      Good luck! Do share your project if you finished it! I would like to see what you make of it! ☺️☺️

  • @kureysalp
    @kureysalp ปีที่แล้ว +1

    Only Physics2D have simulationMode. How did you use it?

    • @ReForgeMode
      @ReForgeMode  ปีที่แล้ว +1

      No, 3D rigidbody also has Physics.Simulate and Physics.SimulationMode. For the implementation, check out my github repo in the description of the video!

    • @kureysalp
      @kureysalp ปีที่แล้ว +2

      @@ReForgeMode I got it now, I am using 2021.3 so only Physics2D have that. For who are using 2021.3, you can disable auto simulation, apply force and torque, get the result, rotate the dice, enable auto simulation and apply same force again.

    • @ReForgeMode
      @ReForgeMode  ปีที่แล้ว

      @@kureysalp Oh, so it's a new addition? Great! Never used Simulate before, so this news to me.
      Glad you managed to get it working!

    • @sirixb
      @sirixb ปีที่แล้ว

      @@kureysalp Hi could you help me to achieve this? in Unity 2021.3