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 Nabster · Jan 31, 2013 at 10:39 AM · javascript

NullReferenceException: Object reference not set to an instance of an object iShake.Update () (at Assets/scripts/iShake.js:32)

I am new to javascript. I am executing the following unity script. I am getting the NullReferenceException on line 32. I will greatly helpful if anyone could identify the problem.

 #pragma strict
 
 import ThinksquirrelSoftware.Fluvio.Emitters;
 
 var accelerometerUpdateInterval : float = 1.0 / 60.0;
 var lowPassKernelWidthInSeconds : float = 1.0;
 var shakeDetectionThreshold : float = 2.0;
 
 internal var emitter : FluidEmitter;
 
 private var lowPassFilterFactor : float = accelerometerUpdateInterval / lowPassKernelWidthInSeconds; 
 private var lowPassValue : Vector3 = Vector3.zero;
 private var acceleration : Vector3;
 private var deltaAcceleration : Vector3;
 
 function Start()
 {
     shakeDetectionThreshold *= shakeDetectionThreshold;
     lowPassValue = Input.acceleration;
 }
 
 function Update()
 {
     acceleration = Input.acceleration;
         lowPassValue = Vector3.Lerp(lowPassValue, acceleration, lowPassFilterFactor);
         deltaAcceleration = acceleration - lowPassValue;
     if (deltaAcceleration.sqrMagnitude >= shakeDetectionThreshold)
     {
         Debug.Log("Shake event detected at time "+Time.time);
     }  else {
         Debug.Log("Shake event NOT DETECTED ");
         **emitter.Emit();**
     }
 }


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

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Wolfram · Feb 02, 2013 at 01:31 AM

The reason is emitter is null. Where/how do you assign to it? Maybe recheck the docs or examples for Fluvio to learn how to properly set up a scenario.

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 weenchehawk · Feb 02, 2013 at 01:11 AM

You may have posted the wrong script - the script you posted doesn't have a line 37.

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 Nabster · Feb 02, 2013 at 01:07 PM 0
Share

Thanks for pointing it out.

avatar image
0

Answer by Nabster · Feb 02, 2013 at 09:44 AM

I haven't initialized the emitter, which can is dont by initializing it on onStart() method.

 emitter = FluidEmitter.FindObjectOfType(FluidEmitter);
Comment
Add comment · Show 3 · 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 Wolfram · Feb 02, 2013 at 11:33 AM 0
Share

a) don't post responses as answers, use the comment button. this is a response to my answer

b) it is impolite to mark your own answer as accepted, especially if somebody else already answered your question correctly (=me).

c) there is no "onStart()" method; code in there will never be executed. use "Start()".

avatar image Nabster · Feb 02, 2013 at 01:06 PM 0
Share

:), You're absolutely right. I receive your answers during the review process of my answer. However, technically, I have posted my answer first.

avatar image Wolfram · Feb 02, 2013 at 01:10 PM 0
Share

Hm, not according to the timestamps shown in the answers.

But anyway, glad your problem is solved! :o)

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

11 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

Related Questions

Cant get my gui in the quiwindow to load there functions... 1 Answer

Objects falling from the specific height randomly. 2 Answers

How to create a game object through a function 2 Answers

invalid cast exception, array of particle systems 0 Answers

Spawning random terrain pieces 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