How do I make a cube roll on a set forward path without it deviating

I’m trying to make a cube roll forward without having it bump left and right by it’s own spinning. So physics causes it to spin around as it rolls, but it doesn’t deviate from the path of going straight forward, and then have it be able to go forward in different directions without path deviation, but still allowing for physics to make the cube spin and jump off the ground due to spinning

You could set up some layers for the physics so that the cube is colliding only with your floor.
Then have a waypoint system (just some empty triggers) that the cube is set to look at. It’ll rotate itself towards them and you’ll just keep pushing it forward.

You could use constant force in the direction you want and freeze the position under the constraints of the cubes rigidbody for the direction you don’t want the cube to roll, play around with adding some relative force or torque in various directions and amounts to make the cube spin and bounce but because of the position constraint it will only roll in that direction. Then i guess you could change that in code to alter what direction the cube rolls just remember to change the position constraint. probably not the best way to do it but should work for what you want sd you should be able to set up some triggers that when the cube hits it, changes the direction the cube rolls.

I figured out a method, I created a ‘move point’ with the cube that sits in front of it however many units away. This move point is stored in a variable in the cube’s script, and I have it combined with another section of code that allows me to turn it so that it always stays a set distance away from the cube, then I take the forward input (whatever it is set to) and apply force from the cube’s position to the move point, multiplied by whatever so it goes faster:

var movePoint = Vector3.forward;
var dir = movePoint-transform.position;

function Update() {
	if ((Input.GetAxis("Forward"+playerNum) != 0)) {
	if (Input.GetAxis("Sideways"+playerNum)) {
		dir = Quaternion.Euler(0,3*Input.GetAxis("Sideways"+playerNum),0) * dir;

    dir.y = 1.48
	movePoint.x = dir.x + transform.position.x;
	movePoint.z = dir.z + transform.position.z;

In my game the cube is scaled to 3, so 1.48 ends up being the center of the cube’s height, so I keep the y on dir set to that so it can still bounce around naturally but doesn’t travel up and down with the cube. Forward line motion isn’t perfect, but it works great to steer a cube around

Here’s a short Youtube video that covers exactly how to roll a cube on its edges: How to Move a Cube by Rolling it | Unity Tutorial - YouTube

rolling cube