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!
Yes i do! Doh!
– BobbleHead