• 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
Question by br.glen23 · Mar 29, 2014 at 11:46 PM · errorcomponent

GetComponent(Script) Error(Won't detect script)

Here is a javascript I have for a camera handler:

 #pragma strict
 
 var cockpitCamera : GameObject;
 var orbitCamera : GameObject;
 var orbitCameraObject : GameObject;
 
 function Start () {
 cockpitCamera.camera.active = true;
 
 }
 
 function FixedUpdate () {
 
     var cameraInput : float = Input.GetAxis("Change Camera");
     var rotateScript = orbitCameraObject.GetComponent(ArcBall);

     //toggle between the two cameras
     if(cameraInput != 0){
         cockpitCamera.camera.active = !cockpitCamera.camera.active;
         orbitCamera.camera.active = !orbitCamera.camera.active;
         rotateScript.enabled = !rotateScript.enabled;
     }
 
 }

For some reason it won't recognize ArcBall as a name of a script I have written, and I don't know why. Do I have to create an instance of ArcBall or something?

Comment

People who like this

0 Show 3
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 getyour411 · Mar 29, 2014 at 11:51 PM 0
Share

Is that the form that needs quotes "ArcBall" in JS?

avatar image T27M · Mar 29, 2014 at 11:54 PM 0
Share

Can you include the exact error you get and make sure the ArcBall script is attached to orbitCameraObject.

Edit: as @getyour411 says, if the ArcBall script is written in C# you need to use quotes.

avatar image Bunny83 · Mar 30, 2014 at 01:35 AM 0
Share

@T27M:
If it's written in C#, the C# script just need to be placed into the plugins folder. If you don't put it in a higher compilation group then you can use the "string version" of GetComponent, but in this case you can't access class specific variables or methods of the class. You just get a Component reference which doesn't even have an enabled property. The best you can cast such a reference to is MonoBehaviour so you have at least the enabled property. You can't get more concrete since the actual class doesn't exist from the UnityScript's point of view.

0 Replies

· Add your reply
  • Sort: 

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

22 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

Related Questions

error with footsteps script 1 Answer

Assets/Standard Assets/Scripts/General Scripts/follow.js(9,59): BCE0044:unexpected char: 0xAD 1 Answer

Hey guys, im starting do make a RPG game and in the Level system script(I called it "PlayerStatsController") i have an error: Parser Error : Unexpected symbol `public'. My script above: 1 Answer

third person controller script has an error on line 193 (bitwise or) 0 Answers

unity script error 1 Answer


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