[4.8.2] Get list of components in actor
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.
asked Jul 25 '15 at 01:16 PM in Blueprint Scripting
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,
answered Jul 25 '15 at 05:28 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here