Hello community, i’ve seen alot of questions but none of them seems to suit my needs. The thing is simple, i will receive an object with a script component of certain type ( say weapon boot or armor ), and i need to store each one in its corresponding array. For example i receive an object with the Armor script attached to it, and i have to store that in the Armor array. The thing is that i cant find a “proper” solution to this, i try’ed using the getComponent but i cant ask if “its not null then add to array”, what i could do is ask if its null, and do nothing, else add to array…but doesn’t seem to be the best approach.
Any suggestions ? Thanks in advance.
PS: about the get component thing:
if(value.getComponent() =! null) //i can’t use the =! on null things
so
if(value.getComponent<Armor>() == null){
//nothing ._.
}
else
Armor.Add(value); //there should be a better way...
tho i didn’t try this so even this may not work.