Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 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 EClancy · Apr 20, 2014 at 01:06 AM · gameobjectraycasttransformgetcomponent

Raycast to Disable Script

I am trying to use RayCastHit to grab a specific script from certain objects, and disable them.

alt text

Hover over reverseGravity: "reverseGravity does not exist in the current context"

Hover over reverseGravity: "?"

Hover over var: "Unknown resolve error"

Could someone show me how to properly find and disable the scripts on these other objects, and explain why? I am used to Javascript and I am writing this in C# for practice.

Also, if you can explain the other two errors (given from hovering over car and reverseGravity), even if they are caused from the first problem.

Comment
Add comment · Show 7
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 robertbu · Apr 20, 2014 at 02:24 AM 1
Share

I'm assu$$anonymous$$g you are talking about compile time errors? And is 'reverseGravity' the exact name of the class or script including the case of letters? It's not 'ReverseGravity' for example?

avatar image EvilTak · Apr 20, 2014 at 04:47 AM 0
Share

In C# you don't write var for initializing a new variable. So if you want to initialize a variable of type lightOn, your code would be: lightOn script = GetComponent(lightOn);

Are the reverseGravity and lightOn scripts written in JavaScript? If so, you will have to place them in a first pass folder like Standard Assets or Plugins. If they aren't JS, then check for errors in the name of the scripts.

avatar image Benproductions1 · Apr 20, 2014 at 01:34 PM 1
Share

@Evil Tak, I'm sorry, but that's just plain wrong. C# has a var keyword and yes it's used for defining variables: http://msdn.microsoft.com/en-us/library/bb383973.aspx

avatar image EvilTak · Apr 20, 2014 at 04:28 PM 0
Share

I'm sorry I wasn't aware about implicit declarations.

avatar image EClancy · Apr 21, 2014 at 01:55 AM 0
Share

Yes, the scripts are in Javascript. How do I add a script to the Standard Assets?

Show more comments

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.

Follow this Question

Answers Answers and Comments

23 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

Related Questions

How to call and run a function from another script on a transform. 0 Answers

How to get info of object within certain range?(Javascript) 1 Answer

Getting a huge amount of errors regarding contained definitions in GameObject 1 Answer

Position of a GameObject 2 Answers

C# GameObjectList not Setting Parent 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