Calling a function within a function

Folliwng on from a recent question, i;'m trying to solve changing control inputs during game, this time I’m trying to put different controls into different functions, and see how that goes, but now I don’t know exactly how call a function from another function…

function Update () {

	if (playerSide1 == false){
		ControlSide1;
		}
	if (playerSide2 == false){
		ControlSide2;
		}
	if(Input.GetKeyDown("space") && !isFalling){
		rigidbody.velocity.y=20;
		}
		isFalling=true;

}		

function ControlSide1 (){

	if (Input.GetKey ("right")) {
	rigidbody.AddForce (Vector3.forward * 10);
}
	if (Input.GetKey ("left")) {
	rigidbody.AddForce (-Vector3.forward * 10);
	}
}


function ControlSide2 (){

	if (Input.GetKey ("right")) {
	rigidbody.AddForce (Vector3.right * 10);

}
	if (Input.GetKey ("left")) {
	rigidbody.AddForce (-Vector3.right * 10);
	}
}

Thats my code so far (negative the declerations and unessential bits) I’m trying to call the other function here:

if (playerSide1 == false){
	ControlSide1;
	}

But it’s not working (probably for an obvious reason).

Also, should I make the control function private? I don’t really know!

you mean like ControlSide1(); ?

You can call any function by just using parentheses at the end, plus filling in any required parameters. In your case the functions have defined have no parameters.

Generally speaking you should keep functions private and only expose them when you want other classes to have access to them. It would probably behoove you to read this article and others like it: http://www.csharp-station.com/Tutorials/lesson19.aspx

To specifically answer your question, you can just call the functions you have declared by putting: ControlSide1();