• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[3D] Rotating a cube

kalzme

Member
Hi,

I've recently started exploring the 3D functionalities in Game Maker Studio 2.3 and ran into a problem which I haven't been able to wrap my head around yet.
I've been reading the manual and following some tutorials on YouTube but it hasn't really given me clarity on this problem.
Needless to say, I'm not at all familiar with 3D concepts and the math behind them just yet.

So, I have this beautiful dice and I'm trying to rotate it to the right (or any direction actually) as if someone were to push it and it would roll over to the side.
In this case it would rotate over the z-axis and end up like the dice on the right with the 5 facing downwards.

The problem is that the origin of the model is in the center of the dice.
Right now I've got this working by just rotating the model 90 degrees over the z-axis and adding the width of the dice to the x position.
This works pretty well in all directions but ideally I'd have a short animation between the 2 states and animating the position and the z-axis rotation doesn't look correct because the origin is in the middle.

Therefore, instead I'd like to change the point around which I rotate the dice so that my animation would be correct.

dice_example_2.png

I'd image that to be able to accomplish this I'd first have to build a translation matrix to change the origin and only afterwards apply a rotation matrix?
And would this still work if I let the player push the dice in all directions and multiple times?

Any help or tips would be greatly appreciated.
 
Top