Another Ball Rolling Game Question

I’ve read a bunch of the questions others have posted here about scripts that you can use to control a ball and make it roll around, and while several of them have helped, I’ve run into an issue that I haven’t yet seen addressed (though maybe I just don’t know where to look).

My ball has a reflective material, so the base texture can be seen rolling but the reflection of the surroundings doesn’t move, obviously. What I’d like is to be able to use WASD to roll the ball using physics, but the different approaches I’ve tried all suffer from the same flaw: once I get the ball rolling in one direction, its axes all roll with it, and my controls depend on the axis orientation to tell the engine which way to apply the force/torque, depending on the script I use. Thus, what is up one moment becomes left or back the next moment, and the game is not very playable like that.

Is there either a way to fix the axes while still allowing the ball to give the appearance of rolling, or an alternate way to apply force to the ball that will not require me to reference the axes? I suspect perhaps the Transform.TransformDirection function is what I’m looking for, but I haven’t been able to implement it without getting serious errors.

I went back to copy my script to this question, and noticed that a change I’d made in the script right before I asked this question was producing an error in Unity. So, I went to correct it, and realized some of my script was missing entirely. Still not sure what happened to it, but when I rewrote it til it ran, suddenly my script does EXACTLY what I wanted it to do. Crazy. I couldn’t tell you what I was doing wrong, which is unfortunate, I’d like to have gained something from this headache, but at least the controls for the ball work right. I’ll post the script I wound up with in the end in the event someone else winds up with the same problem I did.

function Update () {

	if (Input.GetAxis ("Horizontal")>0)
	{
		rigidbody.AddForce(speed, 0, 0);
	}
	if (Input.GetAxis ("Horizontal")<0)
	{
		rigidbody.AddForce(-speed, 0, 0);
	}
	if (Input.GetAxis ("Vertical")>0)
	{
		rigidbody.AddForce(0, 0, speed);
	}
	if (Input.GetAxis ("Vertical")<0)
	{
		rigidbody.AddForce(0, 0, -speed);
	}
}

I just defined a “speed” variable, which I can tweak in-game later on til it’s just right, and viola.