So I’ve got a Blueprint named BP_Rockslide that is made up of 12 “Boulder” static meshes. I want the player to be able to shoot each mesh and destroy them individually but I’m having difficulty figuring out how to trigger the “Hit” action to lower the health of each boulder when they’re shot.
I’ve set up a line trace by channel on my player pawn and if it detects that the hit actor is implementing the correct interface, it sets the Hit Component as a variable and then this is where I get lost. I don’t know how to pass this info over to the BP_Rockslide blueprint and then tell it which boulder was hit so I can take off health.
Here’s my code so far:
Pawn Event Graph:
BP_Rockslide Event Graph:
The problem I’m having is that I don’t know how to call my custom events “HitBoulder01”, “HitBoulder02” etc. Basically I know that I need to set it up so it says something along the lines of "If Component name = “Boulder01” then run the code for “HitBoulder01” but I have no idea how to do this. I can get the Display name of the component but this changes if there’s multiple instances of the BP_Rockslide in the level and I’m also not sure how I can use that info to trigger the various component code.
Also I’d like the be able to have multiple different blueprints that do something different when their component is hit so right now it’s a rock slide, but I’d also like to have something else that the player interacts with (RE shoots) in the future and have that do something different based on the hit component so I’d rather not do the specific checking inside the pawn. I’d rather be able to take the hit component, and then handle the code depending on the BP inside the BP itself. I don’t know if I can use an interface for this or not? Interfaces still confuse me.