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.
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.