Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by ash_richie · Mar 17, 2016 at 05:06 AM · scripting problemnullreferenceexceptionnull reference exception

CAR ENTER EXIT

MY PLAYER GETS IN CAR BUT MY CAR DOENT WORK

HERES MY ERROR-NullReferenceException: Object reference not set to an instance of an object Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.SetProperty (System.Object target, System.String name, System.Object value) car get in.Update () (at Assets/car get in.js:21)

AND

HERES MY SCRIPT -

 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("Car Control script").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;
   }
 
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Brocccoli · Mar 17, 2016 at 02:52 PM

Seems your problem is on this line

 GameObject.Find("Car").GetComponent("Car Control script").enabled = true;

I would seperate the calls into a few assignment statements, debug and make sure you're getting the correct values. One of them is currently null and this part

 GetComponent("Car Control script")

look like the suspect. Is "Car Control script" really the name of the script attached to the game object? I don't think it is. Make sure you have this spelled correctly and EXACTLY as it appears in the Unity GUI.

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

54 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 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 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 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

Null Reference in UnityStandardAssets.Utility.WaypointProgressTracker.Update 0 Answers

NullReferenceException: Object reference not set to an instance of an object 1 Answer

Null Reference Exception on Sprite Renderer 0 Answers

Why cant i instantiate my ship? Error NullReferenceException: Object reference not set to an instance of an object. 1 Answer

Input Working in Editor but not in Build 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