i import basic car and 3d carachter scipt… if i move the caracter autmatly car move… how can i move to the car and press button to change the movement by car??
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();
}
}