Hello!
I get this confusing error and can’t understand what is the case and how to fix it.
What is the difference between GameObject
and GameObject[]
!?
Can anyone please help?
Hello!
I get this confusing error and can’t understand what is the case and how to fix it.
What is the difference between GameObject
and GameObject[]
!?
Can anyone please help?
The problem here is list.Add( obj )
expects a single object while GameObject.FindGameObject**S**WithTag()
returns an GameObject[]
array.
You can fix this by either using GameObject.FindGameObjectWithTag()
(mind the missing s
here) which returns a singe GameObject
OR replace list.Add()
with list.AddRange()
which accepts arrays.