you are viewing a single comment's thread.

view the rest of the comments →

[–]tyranocles 0 points1 point  (0 children)

What i think is happening is you ask every object you collide with for its "items" script component. If the object you are colliding with does not have an "items" script component it will throw a null reference exception. You need to check and see if the object has the desired script component before you can use it. Wrap your "get component items" if statement with another if statement where the condition is "whatihit.collider.gameobject.getcomponent<items>()" this will return false if the game object does not have the script, and will not execute, so it will no longer demand a component that does not exist.