Rolling Ball project

Hi everyone,
I wanted to share a small project of mine. It is just a rolling ball scene but the thing here is ball’s rotation is not fixed. This is all the problem I had so I wanted to share my solution. Any suggestions or downsides you see on my script is welcomed. Wanted to discuss if I am on the right track. Project is uploaded to mediafire I had problem while sending it to unity server it said empty file, I did not wanted to hassle so uploaded to mediafire and here is the script.

Here is media fire link

http://www.mediafire.com/?467h6l1y57x1zm5

var BallItem : GameObject;
var Speed : float = 1000.0;
var HorizontalSpeed : float = 1000.0;
private var Degrees : float = 0.0174532925199432958;
private var FirstBallPoint : Vector3;
private var horizontalSpeed = 100.0;
private var verticalSpeed = 100.0;

function Start() {
	FirstBallPoint = BallItem.transform.position;
}

function Update() {
	var RotationVector : Vector3 = new Vector3(0,1,0);
	var RotationPoint : Vector3 = new Vector3(BallItem.transform.position.x,
												transform.position.y,
												BallItem.transform.position.z);
	var h = horizontalSpeed * Input.GetAxis ("Mouse X");
	transform.RotateAround(RotationPoint, 
							RotationVector,
							h * Mathf.Deg2Rad);
	
 	var CameraPositionChange = BallItem.transform.position - FirstBallPoint;
    transform.position += CameraPositionChange;
    FirstBallPoint = BallItem.transform.position;
    transform.LookAt(BallItem.transform.position);
}

function FixedUpdate () {
	var BallForceVector : Vector3;
	var BallSideForceVector : Vector3;
    if(Input.GetKey("up")) {
    	BallForceVector = GetBallForceVector();
    } else if(Input.GetKey("down")) {
    	BallForceVector = -1*GetBallForceVector();
    }
    
    if(Input.GetKey("right")) {
    	BallSideForceVector = this.GetBallSideForceVector();
    } else if(Input.GetKey("left")) {
    	BallSideForceVector = -1*GetBallSideForceVector();
    }
    
    BallForceVector = BallForceVector + BallSideForceVector;
    
    BallItem.rigidbody.AddForce(BallForceVector);
}

function GetBallForceVector() : Vector3 {
    var yangle : float = (transform.rotation.eulerAngles.y%360);
    var xvector : float = 0;
    var yvector : float = 0;
    var zvector : float = 0;
    if(yangle < 0) yangle += 360;
    zvector = Mathf.Cos(yangle * Degrees)*Speed;
    xvector = Mathf.Sin(yangle * Degrees)*Speed;
    return Vector3(xvector, yvector, zvector);
}

function GetBallSideForceVector() {
	var yangle : float = (transform.rotation.eulerAngles.y%360);
    var xvector : float = 0;
    var yvector : float = 0;
    var zvector : float = 0;
    yangle += 90;
    if(yangle < 0) yangle += 360;
    zvector = Mathf.Cos(yangle * Degrees)*Speed;
    xvector = Mathf.Sin(yangle * Degrees)*Speed;
    return Vector3(xvector, yvector, zvector);
}

My approach is that if ball’s rotation is not fixed than camera should be the position that I should put my self. So I wrote the script to be attached to main camera.

If I increse speed variable the ball is not moving faster at least I did not felt like it. Did I missunderstand or missused the AddForce method?

I found out that we already have a forward vector so I was trying to get the forward vector with GetBallForceVector I am using transform.forward instead now and I solved my force is not increasing when I rise the Speed variable value. The problem was I was changing the Speed default value than I realized that it was always the same with the attached object because if I change it It was not changing the value at the attached one I do not even know why I assumed that it would :sweat_smile: .
So I have a new question now I have a forward vector but how can I get a Side vector I would really appreciate if any of you guys could help me I am newbie with game programming and Unity so as you can guess it is taking a lot of time if try to discover something. Thanks in advance.

Found transform.right Vector from documentation and it is working.