#Better code
1 messages · Page 1 of 1 (latest)
There's absolutely no reason to ever use Find is terribley slow, and uses a string so prone to errors.
You have a reference to the object when you spawn something, so you take that reference and pass it over/ cache it somewhere accessible .. and then create your dictionary with the reference you already have
i can send you the entire code, but you might not understand it.
In fact no one ever did, except me.
You especially shouldn't be repeatidly doing the search. Do it once, cache it, reuse the cached value
what do you think I'm gonna do with the code? 😛
GameObject obj = Instantiate(…,…,…);
Now you got a direct reference to the object without having to use find
idk check if youre right about what you said
Then just add obj to your dictionary
I don't need to check if I'm right, I already know I am
i dont understand this
What do you think it means?
obj is the object youve instantiated
Yes
but to get this reference you first need to instantiate it
Yes
instantiate returns the reference
but in my code, to instantiate it, i need to know which object i should instantiate
which is char11
Right… so when you instantiate “char11”, obj will hold the reference to “char11”