- Home /
Answer by xN811x · Mar 31, 2015 at 10:27 PM
I've never seen these samples and I dont know if this works but it should ^^
The code requires that you have a player and a car object referenced and that both have a Control script which handles their movement You could do something like this:
bool controlState = true;
void changeControl() {
player.GetComponent<Control>().enabled = controlState;
controlState = !controlState;
car.GetComponent<Control>().enabled = controlState;
}
void Start() {
changeControl();
}
void Update() {
//change state with space
if(Input.GetKeyUp("space")){
changeControl();
}
}