• 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
1
Question by Dayne_Neal · Mar 28, 2012 at 06:07 PM · car

Enter/Exit Car

I go this car script from my friend and for some reason it works just fine for him but not for me. Do you guys have any idea on how to fix it?

 var Car : Transform;
 var player : Transform;
 var exitPoint : Transform;
 var doorTriggerLeft : Transform;
 var PlayerCamera : Camera;
 var CarCamera : Camera;
 var isPlayerVisable : boolean;
 
 function update (){
     if (Input.GetButtonDown("Fire1")&& isPlayerVisable){
         //Make player invisable and still standing
         player.gameObject.SetActiveRecursively(false);
         player.gameObject.active = false;
         // Parent player to ExitPoint
         player.parent = exitPoint.transform;
         player.transform.localPosition = Vector3(-1.5,2,0);
         //Parent playerParent to car
         exitPoint.parent = Car.transform;
         exitPoint.transform.localPosition = Vector3(-0.5,2,0);
         // Enable car as controllable object
         GameObject.Find("Car").GetComponent("DrivingScript").enabled = true;
         PlayerCamera.enabled = false;
         CarCamera.enabled = true;
     }
     
     else
     {
         if (Input.GetButtonDown("Fire1")){
             // Make Character visable again.
             player.gameObject.SetActiveRecursively(true);
             player.gameObject.active = true;
             // Unparent Player from everything.
             player.transform.parent = null;
             // Parent Exit Point to Door Trigger.
             exitPoint.parent = doorTriggerLeft.transform;
             // Disable car as a controllable
             GameObject.Find("Car").GetComponent("DrivingScript").enabled = false;
             PlayerCamera.enabled = true;
             CarCamera.enabled = false;
         }
     }
 }
 
 function OnTriggerEnter(Player : Collider) {
     isPlayerVisable = true;
 }
 
 function OnTriggerExit(Player : Collider) {
     isPlayerVisable = false;
 }


Also the I get no error messages from the code when I use it but for some reason I can't get it to actually work. I am also using the Unity Car Tutorial.

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

6 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Nightkilla · Oct 13, 2013 at 10:06 PM

It's function update. It needs to be function Update() {.

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
avatar image
0

Answer by garner · Mar 31, 2012 at 06:01 PM

no errors... kinda hard to know what you are saying isn't working. make sure all the variables are assigned; there needs to be a collider attached to the gameobject; The car object needs to be named 'Car' because its looking for that.. comment things out and work through things.

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
avatar image
0

Answer by Yung-Hustla · Jan 25, 2013 at 01:54 AM

i wrote this script itz totally functional...

Comment
Add comment · Show 1 · 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 nerf zone · Oct 01, 2013 at 01:32 PM 0
Share

I'm using the car from the tutorial too. I changed the find script to "Car" because my car script is Car. but it doesn't detect my Car script.

avatar image
0

Answer by PS3_and_PC_Geek · Oct 14, 2013 at 09:13 PM

I noticed in the code you put function update()

The function Update is supposed to be like this below function Update() Update needs to be a capital letter

Comment
Add comment · Show 1 · 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 Nightkilla · Nov 03, 2013 at 05:40 PM 0
Share

That's what I said...

avatar image
0

Answer by Iron_Games · Sep 02, 2014 at 08:23 PM

I think I can help you, the button to enter in the car isn't the "e" key, it's the right button on the mouse. Click with this rigt button on the car and it works ! Sorry for my bad english, I'm french...

Comment
Add comment · Show 1 · 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 Iron_Games · Sep 02, 2014 at 08:24 PM 0
Share

Sorry, it's the left button...

  • 1
  • 2
  • ›

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

14 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

I made a better shader how do i fix[add _Shadow Strength]help???>Sorry that im asking for to much 1 Answer

Entering/exiting vehicles 1 Answer

someone is there? 1 Answer

Camera follows not right 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