How to make an Enterable/Exitable Vehicle

Hi, I’m kinda new to Unity and I was wondering if it’s possible to make it that when a First Person Controller collides with an object (vehicle in this case) that it will print on the screen “Press E To Drive Vehicle” then you will change to third person and be able to drive the vehicle then press E again to exit it.

I know it’s a lot to ask, but please do your best to answer!

  1. Make a Cube

  2. Remove Mesh renderer

  3. Scale and move to fit around your car (but bigger)

  4. Check the target box on collider

  5. Make a new Javascript

  6. Add:

    function OnTriggerEnter (other : Collider) {
        if(other.gameObject.equals("Player")){
           // Show text!
        }
    }
    function OnTriggerExit (other : Collider) {
        if(other.gameObject.equals("Player")){
            // Hide Text!
        }
    }
    function OnTriggerStay (other : Collider) {
        if(Input.GetKeyDown(KeyCode.E))){
            // Enter vehicle
        }
    }
    
  7. And the rest depends on how your game is and is for you to find out! :slight_smile: