Hey guys, I’ve been building a health system that works off an actor component, so I can attach it to anything in the world and handle it’s health, as well as add a shield and armour. The problem I’m having is I simply want to check if an actor hit by a line trace has this component.
I can’t have had this set up as a interface because I wanted the health to be an isolated thing that could be implemented into anything and keep the same functionality. If someone could help me with this that would be great.
I think I may have a solution for you. I will first post my code and then explain it below.
My code performs a line trace and then checks whether or not the actor who has been hit has a certain component. If it does have the specified component then it will print out a simple string to the screen.
The main part of this code that I think you will be most interested in is the “Get Component by Class” node. This node takes in an actor and returns any components that match the component class that you specify. It will then return an array of those components. This will work nicely if you know the actor only has one of a specific component.
Hope this answer helps,