- Home /
Question is off-topic or not relevant
Check if a value is null from another script?
I have a public Follower named CurrentFollower located in "OneFollower"
But in the monster script, i need to access whether it is null in an if statement. Plus this script isnt assigned to an object.
I just need this to work without giving me the exception "object reference not set to an instance of an object"
I recommend you to create a new empty-gameobject in the hirarchy and assign the script onto that. Then you will be able to access it from everywhere you want and it is not special for "one" gameobject. That's just for getting rid of that error
Answer by fafase · Nov 29, 2014 at 06:30 PM
The answer is in the question.
You want to check if
it is null
, damn I just answered again...
if(reference != null){
reference.Method();
}
Follow this Question
Related Questions
Unity 5 Calling Function From Another Script On A Different Object 1 Answer
How to access a child input field from a parent prefab script. 0 Answers
How to use a float value from coroutine 1 and use in coroutine 2? 1 Answer
Asset bundles and scene references 1 Answer
Losing reference to monobehaviour after updating a dll 0 Answers