Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 davedev · Dec 11, 2010 at 02:35 PM · static

Script Errors with Unity 3.0

This static function now gives in an error in Unity 3.0, but worked in Unity 2.6:

static function map(v1, a1, b1, x1, y1) {
        // returns a value that has the same relation to x and y as the value v has to a and b
        return (v1 == a1) ? x1 : (v1 - a1) * (y1 - x1) / (b1 - a1) + x1;
    }

The error is as follows:

NullReferenceException: Object reference not set to an instance of an object
Boo.Lang.Runtime.RuntimeServices.InvokeBinaryOperator (System.String operatorName, System.Object lhs, System.Object rhs)
Functions.map (System.Object v1, System.Object a1, System.Object b1, System.Object x1, System.Object y1) (at Assets/Scripts/Functions.js:66)
Gauge.setVal (System.Object inputVal) (at Assets/Scripts/Instrument Panel/Gauge.js:37)
Instrument Panel Script.Update () (at Assets/Scripts/Instrument Panel/Instrument Panel Script.js:76)

In addition, this gave an error:

helicopterScript = helicopterGameObject.GetComponent( "Helicopter_Script" );
    helicoperRigidBody = helicopterScript.rigidbody;

Is there a different way now to reference a property in another object's script?

Comment
Add comment · 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 azzogat · Dec 12, 2010 at 12:30 PM 0
Share

The second script doesn't really make sense. You're getting a script component and then trying to access a rigidbody by referencing a script from a GO.

Reference the GO ins$$anonymous$$d through whatever method and call helicopterGO.rigidbody .

avatar image davedev · Dec 12, 2010 at 03:24 PM 0
Share

What you say makes sense, however, early on I found this example in the docs that was setting properties via the script:

transform.Find("Hand").GetComponent(OtherScript).foo = 2;

avatar image azzogat · Dec 12, 2010 at 08:30 PM 0
Share

Yes, that's perfectly viable. But rigidbody is parented to the GO not to the script. so you should do something like:

var handObject = gameObject.Find("Hand") as gameObject; var handRigidBody = handObject.rigidBody;

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

No one has followed this question yet.

Related Questions

Can I run static var from another script ؟؟؟ 2 Answers

Unknown identifier, OnCollisionEnter Error 1 Answer

Global Varible Problem 2 Answers

"transform" in a static function 1 Answer

Changing static variables from another script? 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