H
H
HaKIJLa2021-01-10 12:32:53
C++ / C#
HaKIJLa, 2021-01-10 12:32:53

I want to assign array values ​​from another script to a variable. Why gives Null Ref?

There is a variable A, whose value is equal to the first element of array B. Array B is stored in another script.
I'm trying to get info using GetComponent

otveDrugScr = gameObject.GetComponent<Playzadacha>().praOtvetiMidLvl1[1];

NullReferenceException: Object reference not set to an instance of an object is the error it gives me. I don't know what's the problem. If the mistake is stupid, I apologize. I am new to C# and Unity.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2021-01-10
@HaKIJLa

1) there is no Playzadacha component on the object;
2) praOtvetiMidLvl1 array has not been created.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question