Download

Common Ways of Line Trace Interaction?

What are some of the common ways of setting up a Line Trace for interaction of BP’s / components? Where is the best place to store the line trace code? Right now I have my line trace on an Actor BP that is placed inside the level to determine what is being looked at. So each new level created that isn’t streamed needs the actor to be placed again, is that necessarily a bad thing? Also, when I call disable or enable actor input, it doesn’t seem to be affected…I feel it has other limitations that I am not thinking of at the moment.

Help would be appreciated and thank you for your time.

It’s typical to have the trace inside your character ( if first person ), or possibly from the camera ( if 3rd ). But it’s really up to you.

Another good idea is to have a BP interface on anything you want to get a reaction from , that way the character can say ‘hey, i saw you’ and the object can have it’s own reaction to that ( damage / door opens etc ).

https://www.youtube.com/watch?v=G_hLUkm7v44

Don’t even use line-traces at all if you don’t need to, as they can be harder to debug at game time (unplanned rotations make things interesting etc). Instead, explore if collision volume(s) will get it done instead (Box collision BP’s with BeginOverlap / EndOverlap events), or ‘event driven’ Box collision attached to the Player etc. There’s also the widget-interaction-component (WIC), which offers serious functionality if you need it.

Can’t really comment on the other points as the use case / scenario isn’t clear. For example, where should the Trace code live? Normally a Line trace is part of the Player / NPC (enemy turret etc), rather than some random actor in the level, so that its always available / always works. So overall, place it where its the easiest / simplest to follow / debug, BUT with the least performance impact.

So having this fail if the level isn’t streamed is a warning sign… As is having it running all the time, or if multiple line traces are required throughout the level. So how is this done right now… By Tick or Timer… Could it be event driven instead? Recommend searching on past posts using keywords: Tick vs Timers vs Events etc.