Object reference not set to an instance of an object (143421)

So I have this script that looks at the ground and says, “heay ground do you have Fricion?” and most of the time its all like, “You know I do dog.” But some times it is like “Nope whats that.”

In case of the latter the script is all like, warning warning.
Object reference not set to an instance of an object.
But I want it to be like “that’s cool what evsss.”

how do I make it not give out an error when looking for the attached script.

this is how I am calling the script.

transform.GetComponent(Colliding2).StandingOn.GetComponent(Properties);

can't understand what are you saying. elaborate it kindly.

Make some research before posting thanks http://answers.unity3d.com/questions/47830/what-is-a-null-reference-exception-in-unity.html

1 Answer

1

Your speech is off-putting and very confusing. Proper English may help in this situation. Seems you need to check if the instance is null, possibly something like:

if (TheGameObjectOrComponentYourTryingToAccess != null)
{
	transform.GetComponent(Colliding2).StandingOn.GetComponent(Properties);
}
else
{
	Debug.Log("There is no Instance for this GameObject or Component);
}

Not sure if this will work because you have not given a snippet of code or the line of error; so I don’t know what Object (GameObject or Component) is not referenced.

basically that is all I needed, and it is late here, so that is why my question was making of the little senses. And in the future, the hole get component is what is being referenced, in this case it was a script on another object.

I'll let it slide. It's past 4am here so I feel your pain, haha!