Rolling a Cube

I’m new to the unity engine (I’m sure I’m not the first to say that)

I want to make a cube move around by rotating on its edges, so when forward is pressed the cube rotates on the forward edge 90 degrees.

I’ve had a search around for a tutorial or help but could find anything that worked, could one explain to me how to achieve this?

Thanks in advance

Is your cube just there and you have a player move and push it? If thats the case i think you can use transform.Rotate on the box when the player gets near the cube either using trigger(which i think is easier) or raycast. But if thats also the case, we need to check the axis that the cube is in. Since you say it have to roll forward, you have to make sure transform.Rotate rotates the cube according to it’s local x,y,z, facing.

Rolling a cube is challenging because as it rotates it has to move slightly up and down (otherwise the edge would go through the ground and that would look strange), so I think the easiest thing would to just animate it rolling and just play the animation while you move it forward.

I found a tutorial that used transform.Rotate however when it does rotate the cubes falls through the ground.

If I create an animation can I assign it to a key? So pressing Up activates the forward animation movement?

What if you had an invisible object push the cube a certain way, rolling it?

  1. use physics to roll the cube
  2. give the collider a high friction, low bounce physics matieral
  3. give the cube’s rigid body a high drag to stop it flying away
  4. use add force to push the cube around
1 Like

Could people go into more detail please, I fairly new to unity so I’m still learning what certain things do, Thanks

Also I followed this tutorial Unity Noobs: Roll a Cube.
I moves the cube the way I want it to but there is no gravity physics and the cube falls through the floor if the platform is raised.

I would like to create the movement from scratch so that I get a better understanding of Unity and Java

Just to go into more detail; when the player presses the right direction the cube moves right by rotating on the right sided edge (I hope this makes sense) I want to do this for all directions (up, down, left, right).

With this I also want gravity so if the cube moves off the platform it falls down, I can’t seem to get both the movement and gravity at the moment.

Here’s a quick tutorial on how to achieve it:

1 Like

cuz my cube has a mass of 1e+09 lmao