#Variable in my foreach loop isnt changing.

1 messages · Page 1 of 1 (latest)

thorn rock
true gazelle
#

obj.gameObject
This is redundant, Instantiate returns a GameObject so you can just use that

#

This For loop will only run once so there's no sense in using a loop as you have break outside the if statement

#

Foreach will also only run once before breaking out of it

thorn rock
#

oh thank you!

#

that fixed it

true gazelle
#

Also no idea what this is doing Lmfao You have item and Item but Item is the class I believe

#

Debug.Log(Item);

#

obj.gameObject.GetComponent<ItemController>().item
This can also be cached

#

so

#
ItemController controller;
obj.TryGetComponent(out controller);