Z
Z
Zimaell2020-10-23 10:41:35
Unity
Zimaell, 2020-10-23 10:41:35

What if it gives an error that there is no object, but it is?

I instantiate an object like this

Field[x, y] = Instantiate(RandomCell, new Vector3(x, y, 0), Quaternion.identity) as Cell;
Debug.Log(RandomCell);

in this case, the object is displayed on the screen at the desired coordinates, that is, it appears in the hierarchy at startup, but also displays an error
Object reference not set to an instance of an object

By the way, the debug does not work anymore, because it thinks that there is an error in the instance line.
And here, as it were, a question - this error pops up if "the reference to the object is not set to an instance of the object." At the same time, the object is on the screen and also displays an error ...
How can I not understand ....

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-10-23
@Zimaell

So split your line in two, creating an object and storing it in an array. And you will see that the problem you have is not in the creation, but in the fact that there is no array.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question