Line Tracing Issues

Right so I have a problem and I was wondering if anyone could help. I have set up a line trace so that when it hits a blueprint it sets triggers a custom event which changes the material (I’m making an intractable monitor like the one in prey) but I only want the monitor to tu

rn on when my line tracing hits a collision box. Any ideas how to do that?

Right so I have a problem and I was wondering if anyone could help. I have set up a line trace so that when it hits a blueprint it sets triggers a custom event which changes the material (I’m making an intractable monitor like the one in prey) but I only want the monitor to turn on when my line tracing hits a collision box. Any ideas how to do that? (No idea why it uploaded funny)

After your line trace, you do a “Cast To Pannel”, which if successful calls Hit Box.
Basically your saying “If my line trace hits a Pannel then change the Material of Pannel”

From what I understand you want something like “If my line trace hits a Box Collider then change Material of Pannel”
So I would suggest changing your “Cast To Pannel” node to “Cast To …” whatever class is your Box Collider.

Let me know if that helped.

Add collision box as a component of your monitor BP. Assign a custom event in your monitor BP to the hit event of your collision box component. Set your collision box to only collide with Visibility channel (or some custom collision channel you want to set up just for traces like this). You can set collision for “Query only” as well, no physics. Also make sure your collision box component is set to generate hit events. On each hit you can set your dynamic material parameter as you please. I don’t know how the Prey monitor works, but from here you can track monitor ON/OFF state with a boolean, or have a cooldown timer to prevent the monitor flickering on and off. You also might want to track what you’re currently hitting in the Pawn class (or wherever the trace is coming from) and do cast checks (Q-tro mentions this above) to track when a given object (like the monitor) starts and stops getting hit.

Ah, I didn’t see all your screenshots. So it looks like you have the box already as a component of your Pannel class. In that Actor cast you can get a reference to the Pannels box component and see if it is == to the “hit component” on your hit result. If it is, then call the Pannel classes Hit event.

I got it working, I set up the monitor to a separate collision type to the box collider, atm I am trying to set up a highlight feature so if the line trace collides with the box collision it changes the material (to make it look highlighted). But I need it to change the material back to its original material in order to make it seem like the player has highlighted a button. I have set up a constant line trace so when I move over the box collider in the BP it changes the material, but I can’t figure out how to change it back when it’s not colliding with that box collider.

One way to do this would be to keep track of everything you hit with that trace in an AActor ref variable. So you would do a compare after every hit to see if it’s the same actor or component you hit previously. If it’s not the same actor then you know to call the newly hit actor’s “BeginTraceHit” function (“HitBox” as you have it now) as well as the previous actor’s “EndTraceHit” function. And if it’s the same actor as hit previously you do nothing. Make sense?