"NullReferenceException: Object reference not set to an instance of an object GameHelper.Update () (at Assets/Scripts/GameHelper.cs:44)"
Hello people. I am new to Unity and been trying to write a code for my first game. Almost everything was done but this notification poped out:
"NullReferenceException: Object reference not set to an instance of an object GameHelper.Update () (at Assets/Scripts/GameHelper.cs:44)"
I know there are many different questions that had been asked about the same topic, but I couldn't find answer for mine. Any help would be much appreciated!
Here is my cod:
42 if (SelectedBirdHelper != null)
43 {
44 SelectedBirdHelper.GetComponent<Rigidbody2D>().isKinematic = false;
45 SelectedBirdHelper.GetComponent<Rigidbody2D>().AddForceAtPosition(
46 SelectedBirdHelper.transform.right* 1000,
47 SelectedBirdHelper.StartPosition
Answer by UsmanAbbasi · May 10, 2016 at 09:44 AM
Check if gameobject "SelectedBirdHelper" has "Rigidbody2D" attached with it or not. Maybe it is not attached which is causing null reference error.
Answer by Ararat13 · May 11, 2016 at 07:33 AM
In my case GameBirdHelper is an c# script which refers to my RedBird sprite, which has a Rigidbody2D.
Your answer
![](https://koobas.hobune.stream/wayback/20220612080511im_/https://answers.unity.com/themes/thub/images/avi.jpg)