Getting GO with specific scripts on it

Hello

I use a public method reference to one specific target

I use something like this :

target.GetComponent().health();

My issue with that is that it works for that ONE target, but I want it to work with every GameObject containing the MyScript.

what would be the way to do that ?
Thank you

Meaning that every GameObject I hit which contains that script should be affected. NOT that I hit one and then every one with that script gets impacted

Are you looking for FindObjectsOfType()?

Before going too far into using it, review the documentation to consider possible performance implications.

1 Like