#Null Ref

1 messages · Page 1 of 1 (latest)

silent needle
#

Here's how I would approach it

#

instead of having that one long line starting with bbb, split it into multiple lines. Is the error referencing that line?

sharp quail
silent needle
#

well I suggest you do

Debug.Log(yes.gameObject)
bullet_tempscript theScript = yes.gameObject.GetComponent<bullet_tempscript>();
Debug.Log(theScript);
Debug.Log(theScript.damage);```

One of those has to be null
#

And if you're saying you already know that damage is null, then why are you worried about the null ref exception?

sharp quail
silent needle
#

well one of those things is obviously null. You're saying you already did this?

sharp quail
#
Debug.Log(yes.gameObject.GetComponent<bullet_tempscript>().damage);
#

this line also has nullref

silent needle
#

Yes, that doesn't tell which component of that line is null

sharp quail
#

its the damage component

silent needle
#

bullet_tempscript?

sharp quail
#

yeah, its the damage variable

#

if i just doDebug.Log(yes.gameObject.GetComponent<bullet_tempscript>()); it doesnt have an error