I have been trying to create a code for entering and exiting a vehicle. I have been using the following:
`var carCam :Camera;
var walkCam : Camera;
var on :boolean;
function Update()
{
if(Input.GetButtonUp(“action”))
{
on=true;
car.GetComponent(carController).enabled=true;
carCam.enabled=true;
walkCam.enabled=false;
}
else
{
on=false;
car.GetComponent(carController).enabled=false;
carCam.enabled=false;
walkCam.enabled=true;
}
}
`
when game starts, walkCam is on first. when i press the action key it switches to the car, but when i press action key again, it just stays on car. I am not the best at scripting and i have been searching for weeks as well as reading the scripting reference nad no luck, im not sure what im doing wrong. How can i make it so i can enter and exit a car?