How do I create 3D dice with rotation?

0 favourites
  • 11 posts
From the Asset Store
a basic game template with which you can show your own creativity with interactive and exciting rolling of ion dice!
  • Hello!

    It's been years since I last used Construct but the new 3D features intrigued me so I got a license to try them out.

    As the title says, I am trying to figure out if there is a way to create 3D dice that can be thrown with a random rotation and finally land on the level.

    I made a few attempts with the 3D shapes but I cannot seem to get how to simulate Z rotation.

    Thanks in advance :)

  • Hi,

    Currently the 3D in construct is pretty limited. What is provided is a way to move and rotate the camera, as well as the 3D object. The 3D object is limited to a few primitives and can only be rotated on the z axis.

    There is also a third party plugin by mikal that lets you load other models, as well as more rotations.

    Beyond that there is also mesh distort which can let you make meshes that way. However you have to really get into the weeds of the math to do it with that.

    3D physics is another can of worms. Either do it from scratch or use a js library to do it. Although either aren’t simple.

    Anyways, 3D isn’t there yet to do what you want to do easily.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the quick reply R0J0hound

    I guess I will have to wait and hope the construct team will work more on the 3D features of the engine :)

  • An ugly verlet physics die.

    dropbox.com/s/zis7zp6rggxpdny/dice.c3p

  • That's really sick! Cool 3D dice you have there R0J0. Utilizing mesh distort is clever solution within math behind it.

  • Thanks. The mathiest part is the random orientation bit. And the random velocity.

  • Very Cool.....

    Thanks a lot

    An ugly verlet physics die.

    https://www.dropbox.com/s/zis7zp6rggxpdny/dice.c3p?dl=1

  • May I ask, how can I change the angle of the rolled dice? because surface of the top of dice viewing angle is too small.

    If I want to have roll two dices, what should I do?

    Thanks. The mathiest part is the random orientation bit. And the random velocity.

  • For the view, you just need to change the 3D camera angle. But if I pick this up again at a later date it can be made to have a different sloped ground and direction of gravity to make change the view of the dice.

    To have two dice? Hmm... right now it’s not very modular. One way would be to clone all the object types and make the cloned instance have the same values in the instance variables. Then duplicating all the events and using the replace object feature to make the duplicated events use the cloned objects.

    Even then the two dice won’t interact with each other without further collision code.

    In general I just need to revisit this eventually and make it more modular.

  • R0J0hound You have created a very creative source.

    And I have a question,

    How to determine which face is on top?

  • There’s a newer version of this floating around but it must be on another topic.

    Anyways to decide what face is on rope you can do a dot product with all the face normals and the one that’s the most positive is on top.

    Typically you’d calculate the normal using three vertices from each face and doing a cross product. However since it’s a cube you can get the normal from just two vertices: one one the face and one on the opposite side of the cube.

    The strategy I’d go with is make a list of those two vertices for each face and put them in an array sized 6,4,1.

    At(I, 1) would be the first vertex, at(I,2) would be the second. For bookkeeping you’d set at(I,3) to the face value. You’d set at(I,0) to the dot product of each pair to the ground normal. Roughly:

    Dot= (v2-v1) dot vec(0,0,1)

    Then you’d sort the array and the first index will be the top face.

    That’s the general idea at least. It’s just busy work to work that out. Another idea would be to calculate the orientation and work out a formula to spit out the top face.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)