Usually, I would use FindComponentByClass<>() on actors that may or may not have the component I’m looking for (meaning the component isn’t standard to my class). But if you know that your AMainCharacter will always have a UHealthComponent, then make it a UHealthComponent* property on your AMainCharacter class and access it directly (or if you want to keep it a private member, add public accessors to its data) – no need to search all components for the one you’re looking for if you know it’s always supposed to be there.
2 Likes