Rolling cube | How do you make it

Hello,

It has recently caught my interest that I would like to create a rolling cube.
image


The cube shall roll.

- Best regards, iSyriux

3 Likes

You could use BodyGryo to manage the Cube’s orientation.

2 Likes

Not sure if something like this is what you’re after, but a really hacky solution is to surround all 6 sides of a Ball shaped Part with SurfaceGui’s, and insert a Frame into each one. Since they’re square, you’ll end up with something that looks like this, while still maintaining the physical properties of a sphere (since GUIs don’t have physics or anything of the sort):
image
(one of the sides is Visible = false so you can see the sphere underneath)

1 Like

You can weld a can-collide false block to the center of a ball to obtain this same effect, just simpler to do (granted you have a welding plugin) in my opinion!

1 Like

Pretty sure the downside is that he wants the cube to roll using the torque of each edge of the cube like pushing a large cube with large weight then it would roll not like a sphere but like roll between on each edge (i’m sorry if you had a stroke)

Otherwise it’s a square block just rolling like a sphere without the physic where it just looks like a square not making contact on any part it rolls on except its not going to fall through.

1 Like

I think you can rotate the cube around a pivot position. But, pivot should be a edge.

images from: Understanding CFrames

In a case like that just put a BlockMesh in a Ball and increase the scale of the Mesh to slightly under the diameter of the Ball.

I believe what you’re looking for is related to the cyclogon of a square

and roulettes. Hopefully those two terms can assist your search.

6 Likes

Hello,

Thanks for all the replies everybody.
For @Auxthic, how would I be able to control the bodygyro? I would like to be able to make something like a marble race, but with cubes that roll. I would like to be able to control it with WASD key.

For @punyman9, unfortunately, a hacky solution for something my game will be entirely based off of is not a solution at all.

For @outcharm, the same applies to you, for when I told @punyman9

For @reygenne1, I totally agree. This is the reason I made this thread.

For @Infi_power, manipulating the cframe of the cube itself would not take into account physics, as I would like this to be a physics thing.

For @Scottifly, the cube would look very strange when rolling, and that too, is a hacky solution.

For @AstroCode, your insight is very helpful, however I do not know how to apply the mathematical equations in the link you sent into my game, how to control it, and such.

- Best regards, iSyriux

I don’t believe changing the orientation property of the cube would be the optimal solution, as I think it would end up cutting into the ground; give it a shot though. The way I’d do this is with a BodyForce, AngularVelocity, RotVelocity, or Torque Constraint, that applies force at an angle to the cube. Either

  1. Apply angular/rotational force to the cube
  2. Apply directional force at an angle to the cube

I’d likely choose the former, as it would give a more consistent result. Perhaps try experimenting with AngularVelocity or RotVelocity. Simply said, AngularVelocity is a force applied to the part, and RotVelocity is directly changing the part’s property of rotational velocity.

Hello,

One problem with using AngularyVelocity is that it apparently doesn’t account for gravity, and a cube that’s rotated 35 degrees on whatever axis that’s in front of it should fall down and become 0 degrees on whichever side is closer to the ground. That’s usually the case without AngularVelocity, but as you will see in the video in the moment, AngularVelocity completely negates that, and not only that, the other cube has trouble with climbing even an 11.25 degree gentle slope, and my racing game will include hills and mountains and such. What do I do to solve these two problems?

- Best regards, iSyriux

Hello,

- Best regards, iSyriux

Sorry for the late reply; I figure that .RotVelocity could work for you. Try setting the .RotVelocity property inside of a script rapidly, so that it does not change. Something like this:

local myCube = script.Parent

game:GetService("RunService").Stepped:Connect(function(time, step)
    myCube.RotVelocity = Vector3.new(20, 0, 0) -- Change the Vector3 values accordingly to your needs
end)

This should be setting the rotational velocity of your cube instead of applying an angular force. Let me know how it goes if you’re still working on this.

1 Like