Get in and Out of a car.

Hello,

My name is peleg and i'm building a video game with unity pro. I Got to the point where the FPS player is done, and now i'm programing the car. Now, i am a pretty bad codder (more of a designer), i have managed to make the car drive(pretty much poorly), but i couldn't write a script how will make the player get in and out of it.

now, the basic idea that i thought on is that when the player will be close enough to the car and the proper key will be pressed, all of the player components will be disabled, and all of the car Comp's will be enabled, and the player will be set to a point where you cannot see him (below the terrain for example).

i would be glad if some one could help me write the script (of course he will be credited).

Thanks for helping, Peleg Gefen.

For the car control script take a loot at this guide, if you tweak it a little you can get a racing car with a great 'feel' to it.

For the script to get in the car, and this is just an idea I'm sure there are better solutions, I would do it as follows.

In the script attached to your player set a variable that keeps track of the distance to the left cardoor. If the distance is smaller then let's say 1 meter a nice little GUItext appears saying something like 'press space to enter'. Upon doing this, simply disable movement and rendering of your character, no need to transform him to a place where he cannot be seen. Now of course activate car controls. When in the car you press space, disable car controls, transform the position of your character to next to the car and enable movement and rendering again. I hope this helps, I'm not actually going to write the script for you =p

I know it’s stupid question, but how can I disable controls?