transform code!

Is there a code in javascript or any other programing launguage in unity to transform one object into another for example

if my person (object 1) it within a distance of (lets say object 2) and you hit the button e you transform into object 2 destroying the original object of object 2(the one you were next to)

I would like the script so i could change my person into a car (therefor i would just have the car as a fps controler and you could drive around)

thx i know this is complicated but try and make sense of it

This is how you do it in javascript-

var obj1 : Transform; //this is you
var obj2 : Transform; // this is object2
var transformDist = 30;// this is the distance

function Update(){

if((distance >= Vector3.Distance(obj2.position, transform.position)) && (GetButtonDown("e")))

function transform(){

Destroy(gameObject); //destroys your player
var replace = Instantiate(obj2, transform.position, transform.rotation); //this instantiates object 2 

//drag your player on the obj 1 slot and the car to obj2 slot 
//P.S. I haven't tested this script