x


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.

more ▼

asked Feb 27 '11 at 07:19 PM

Jankrap gravatar image

Jankrap
1 2 2 2

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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

more ▼

answered Feb 27 '11 at 08:00 PM

Joshua gravatar image

Joshua
6.5k 19 25 72

(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered May 25 '11 at 06:53 PM

szymciolop gravatar image

szymciolop
1 2

This is merely not an answer to the topic. ;) Use search or if you have a hard time finding post a new question http://answers.unity3d.com/questions/ask.html

The answer is as easy as an if-statement, if(!gamePaused){//steeringcode} for instance.

May 25 '11 at 07:16 PM save
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5271
x831
x423

asked: Feb 27 '11 at 07:19 PM

Seen: 1837 times

Last Updated: May 25 '11 at 07:35 PM