What is wrong with my code?? I want to find 3 sprite names on the array but this one doesn’t seem to work.
Tried to search only one and it worked but when I added 1 more condition it just does’t work.
if (allItems.sprite.name == “hammer_inv_selected” && allItems_.sprite.name == “blah blah2” && allItems*.sprite.name == “blah blah” )*
I also tried this this…
if (find sprite 1)
if (find sprire 2)
if (find sprite 3)
this one works but sometimes it doesnt… it’s not consistent. can someone tell me why??
sometimes I only get 2 sprites and it wont give me the third one._
Not 100% sure since the entire script wasn’t given, but the possible reason it isn’t working is maybe you’ve put the code under void Start () instead of void Update ().
for future reference only I’ve found the solution.
what didn’t work for me:
if (allItems<em>.sprite.name == "hammer_inv_selected" && allItems_.sprite.name == "blah blah2" && allItems*.sprite.name == "blah blah" )*_</em>
if (find sprite 1)
if (find sprire 2)
if (find sprite 3)
if (find sprite 1) if (find sprire 2) if (find sprite 3)
what worked for me using tags:
if (count == 2 && GameObject.FindWithTag (“hammer_selected”) && GameObject.FindWithTag (“nails_selected”) && GameObject.FindWithTag (“stool_selected”))