Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Bruno-Fludzinski · Jul 01, 2012 at 10:24 PM · carexitenterenter-car

Entering And Exiting Car

I know this question is asked a lot but I can't figure it out. I have a car with this script:

 var FrontLeftWheel : WheelCollider;
 var FrontRightWheel : WheelCollider;
 var GearRatio : float[];
 var CurrentGear : int = 0;
 var EngineTorque : float = 230.0;
 var MaxEngineRPM : float = 3000.0;
 var MinEngineRPM : float = 1000.0;
 private var EngineRPM : float = 0.0;
 
 

 
 function Start () {
 rigidbody.centerOfMass += Vector3(0, -.75, .5);
     }
 
 function Update () {
     
     EngineRPM = (FrontLeftWheel.rpm + FrontRightWheel.rpm)/2 * GearRatio[CurrentGear];
     ShiftGears();
     audio.pitch = Mathf.Abs(EngineRPM / MaxEngineRPM) + 1.0 ;
     if ( audio.pitch > 2.0 ) {
         audio.pitch = 2.0;
     }
     FrontLeftWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * Input.GetAxis("Vertical");
     FrontRightWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * Input.GetAxis("Vertical");
     FrontLeftWheel.steerAngle = 10 * Input.GetAxis("Horizontal");
     FrontRightWheel.steerAngle = 10 * Input.GetAxis("Horizontal");
 }
 
 function ShiftGears() {
     if ( EngineRPM >= MaxEngineRPM ) {
         var AppropriateGear : int = CurrentGear;
         
         for ( var i = 0; i < GearRatio.length; i ++ ) {
             if ( FrontLeftWheel.rpm * GearRatio[i] < MaxEngineRPM ) {
                 AppropriateGear = i;
                 break;
             }
         }
         
         CurrentGear = AppropriateGear;
     }
     
     if ( EngineRPM <= MinEngineRPM ) {
         AppropriateGear = CurrentGear;
         
         for ( var j = GearRatio.length-1; j >= 0; j -- ) {
             if ( FrontLeftWheel.rpm * GearRatio[j] > MinEngineRPM ) {
                 AppropriateGear = j;
                 break;
             }
         }
         
         CurrentGear = AppropriateGear;
     }
 }

And It works fine but I want to be able to (When I'm close to my car, press "return" and then I get in my car and I can Drive that; my player disappears. Can Someone please Walk me through on how to do this?

Thanks so much in advance

-Bruno

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by nixtwiz · Jul 05, 2012 at 05:24 AM

Vehicle Enter/Exit Script

The script/tutorial is in one of the answers. To walk through the script quickly,

1.the player is touching the enter collider and presses key 2. the player's location is changed to the car's and it is parented to the car 3. the player is made invisible 4. the player is disabled 5. the car is enabled 6. Player camera is disabled 7. car camera is enabled

This video helps you set it up, you might need to watch the other two as well. Entering and Exiting Vehicles

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bruno-Fludzinski · Jul 05, 2012 at 06:56 PM 0
Share

nothing happens I did everything in the tutorial- nothing

avatar image nixtwiz · Jul 05, 2012 at 09:55 PM 0
Share

Did you follow all the videos? most importantly the correction video, he messed up in the first one.

I know the script works, I've used it myself numerous times. Double check with the videos that its set up correctly :)

avatar image SohaibShah · May 29, 2016 at 11:44 AM 0
Share

Are u sure that the video works? Because i am a very young developer of 10 and a half years so i need a free working script for my game. plz help u need email?here it is: shahsohaib09@gmail.com help plz...

avatar image
0

Answer by waqas007 · 4 days ago

Visit this link for car enter exit system: https://incern.blogspot.com/2022/06/car-enter-exit-system-c-unity-demo.html

Watch this Video for car enter exit system: https://www.youtube.com/watch?v=gLu3g_iNQDE&ab_channel=WaqasKhalid

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

JS Enter Exit with NetworkPlayer 1 Answer

Enter/exit buildings spawn 2 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Enter/Exit vehicle 0 Answers

could someone help with entering/exiting a vehicle? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges