Simple Line Trace Fail?

Hello everyone!

I was trying to find a bug regarding a line of sight check with enemy AI when I stumbled across a very odd … bug?
Not trying to blame the engine (god no, UE4 is amazing), but I just couldn’t get a single line trace to hit a moving object (character actor).

After doing some research in the answer hub, it really seems like a bug in the engine that causes this, because quite a few other people also couldn’t get it to work and they all suggested some work-arounds to avoid this method entirely.
But seriously, this should be such a simple thing, I’m probably not reading that correctly, it’s a misunderstanding and or I’m just doing something wrong here.

I’ll attach my setup in a picture and believe me, I’ve tried all day to figure out why this simple line trace for object doesn’t work (also line trace by channel doesn’t work here either).

What I’m doing here is a simple “Line Trace for Object” and all the objects I’m looking for are of type “Enemy”. But it never hits anything. When I change the type to anything else, it works. Also if I change the type of the enemy back to the original “pawn” and try a line trace for that, it also doesn’t work.

Also changing Trace Responses to Block still doesn’t change anything.
I always get false.

Hello,
You may have better results if your trace response visibility is set to block (if not the trace overlaps your actor.) and collision to collision enabled. And check if your mesh has collision. Have you try “block all” preset ?

Edit : and be sure that your trace is not stopped by something on the way to your actor.

I set everything to “BlockAll” - still the trace goes right through the enemy and shows “false” as result.

Btw I want the trace not to be stopped, so “block” isn’t what I’m looking for either way. But even for testing purposes it doesn’t work.

Ok, try to set your array object types to static / dynamic / pawn and drag a break hit from hit output and print other actor output to see what you hit. Then you’ll know if your issue is from your linetrace or from your blueprint. (use a tick event / delay 1s to test to not have to click “t” a lot".

Okay, now after this test it seemed to hit the enemy. But only when I have “World Static” as part of the arrays. When I remove “World Static” as one of the arrays, it doesn’t register the enemy anymore. I’ve checked inside the Blueprint of the enemy, there is nothing set to static and every collider and mesh is set to movable.

To have your linetrace working, go with static in your array and from the break hit other actor drag a “cast to” enemy. Set it on your exe output and you will see it only.

Thank you Fen, this works.
But honestly, this is another workaround of many others I’ve found when the same question was asked.
Could it be that this is some strange glitch or something that causes this?
Because normally when I check for Enemy and the enemy is clearly labeled Enemy, it should detect the hit when I do a trace. Having to look for a World Static and then filtering out the results to get the enemy seems very weird, especially when the object is not even marked as static in any way.

One more question, if I want to filter for more than only one type of object, do I use a sequence and make another cast to?

Personally, i used a second and a third “cast to” from the fail output of the first and then second ones. But i focused only 3 types of blueprints (usable items parent, activable items parent and characters parent (enemies and allies being distincted by a var in parent). Sequence will check them all each every time. In cast order, set first the more encountered if you can and then the second one.

Thank you very much, your solution is way more efficient :smiley:
Thanks!