LineTracebyChannel & Set custom render

Hi! What I’m trying to do should be quite simple: I have a line trace that is called every frame, and when the line trace hit my interactable object it should highlight, indicating to the player that he can grab that object. I have a custom channel for that, and all I need is to get the Hit component in the BreakHit node, and set the custom render depth to true or false, depending if the line is hitting something or not.


This is the entire blueprint for that logic, but when I hit play and test it, It works as intended, but not when I move the line trace away.

I can even detect normally if the component is valid or not, I have no idea why It says that has accessed none

You have to turn the custom depth off again :slight_smile:

It’s a bit of a fiddle, actually. How I did it, was to make a parent class ‘interactive object’, and the player sends highlight messages to it using a blueprint interface. The interactive object has a timer, and if the player isn’t sending ‘highlight’ messages anymore, it un-highlights itself.

Just setting and unsetting the highlighted object doesn’t work, because you don’t know another object will be highlighted until it’s too late. Then you don’t have the reference anymore…

1 Like

hi @TheBigBr0

you need to check the hit is valid before setting an object to a hit actor

on the line trace by channel, there is a boolean value below called “Return value”

Branch check that first before set mag object, connect the true to set mag object and false to nothing unless you want to do something if not but that would happen ALOT as its on tick

I’ve done that, and now It turns the highlight on and off as intended, but it still gives me the error

I’ve tried using blueprint interfaces and event dispatchers, but the plan is to have like a hundred of this objects for the player to interact (It will be metal parts that he can throw to do damage or defend himself) and when I highlight one, it highlights all objects in the scene, so I’m trying to set the custom render while is being hitted to avoid this problem.

I hear you.

But you can’t do it from the player ( or level BP ). The objects themselves need to know how to un-highlight. That’s why they need to be blueprints.

Here’s my code ( it deals with multiple components )

You don’t need multiple components, so it will be more simple.

1 Like

you are trying to grab the data from a set node that hasnt been initiated as you hit a false trace. Try dragging a get node of LookingMagObject into the target pin on the bottom render depth node. might not make any difference but try?

Tho blueprint actor is a much cleaner choice as @ClockworkOcean suggested

I was able to make it work using a IsValid? node in the False output of the branch, now It works and with no errors!

It was really the branch that made the difference, thanks!

Not to mention when the player decides to waggle the mouse around a bit, and you hit 15 objects in 25 frames. How do you keep track of that!? :slight_smile:

1 Like

The problem is when you go straight from one object to another…