Camera enable/disable problem.

I have this car with some cameras and they need to be disabled when I exit it and enabled when I enter it and change camera view. However I need to use only 2 buttons in order to do it. One for getting in and out and 1 for changing.

Ok so all that pretty much works except that after I exit the car all cameras get disabled on exiting with the same button that I enter the car with. So when I want to renter the car it disables the cameras.

I would I stop it from disabling going in whilst making disable going out?

Code:

//This is on exiting.

public Camera camera01;

if(Input.GetKeyDown(KeyCode.E)){

   camera01.enabled = false;




}

//This is on entering in the player script, the exiting is on the cars script.

// the CarComp is the script that gets enabled and along with the cameras attached to it. This is the script from above.

if(Input.GetKeyUp(KeyCode.E)){

   vehicle.Getcomponent<CarComp>().enabled = true;



}

So again my problem is that I need the the E button to not disable cameras on getting into the car but do disable them while getting out.

Well duh! Unless you have forgotten to post any other code, your activation is happening in Start which is only called once in the life-time of an object. So once you deactivate, you never activate again.

As @TrickyHandz suggested, use OnEnable() instead of “Start”. You may also need to create some flags to maintain state.