Calling on custom events through tracing

Hi, so I’m trying to create a custom event that fires a print string when called upon in the blueprints using tracing. What I’m trying to make happen is when I toggle my trace from my player and it hits the actor that the custom event is attached to it’ll fire the print string attached to the custom event. My problem is that I’m really new to this and I’m unsure how to make that happen I’m just looking for suggestions on how I should approach making this happen.

It’s not an optimal way, but it’s pretty easy to use.
When you traced Actor1 in Actor2 you can cast to the Actor2 and change a variable in Actor2.
Actor2 might have the logic that is checking the variable for each frame and do something with this. In your case, I’d use a boolean and simple branch, if it’s true I will print a message.

Let’s start by enabling you to toggle line trace for your character at the push of a button.

This is a blueprint that only has a static mesh (cube) and this custom event written within it:
image

Now we head to our Character bp (player) and make a button toggle line trace once like so.
This is the line trace logic:

After breaking the hit result of the trace we cast to our object bp and drag the custom event from it like so:


ddd

However, using the Cast method is not that practical when you have many different blueprints that all share the same custom event, for that matter, I heavily advise you to look into Blueprint Interfaces, they are fast, clean and practical. This would do it for now don’t worry.

2 Likes

Ya I’m working on this for a class I’m in that’s just for learning some simple basics but this helped a ton so thank you.

1 Like