Single Line Trace somtimes goes through landscape

Ok ! I did tries and only case i got issue is with trace complex checked.

With trace complex unchecked there is not a single trace going through the landscape? You have to move the mouse around a bit and set the trace debug type to persistent…
I tried trace complex enable/disable many times, it doesn’t make any difference for me.

Other thing different i got was the player controller, i got the green one. All other was the same. And i got weird lines, not player ones like when i use eye position for example.

What green one?

This green one :

https://docs.unrealengine.com/latest/images/Gameplay/HowTo/ActorInput/Blueprints/input_1.jpg

Well, I use the same one, I just looks blue on my screenshot because I use a custom function which gets the player controller and casts it to my own one.

Ok, then the only difference is the trace complex checked box which is the only case where i got your issue for all the tries i did.

This might be some engine stuff. In a project i had an issue with not existent collision myself. I had some meshes with hitboxes wich were overlapping. After a certain amount my trace didnt hit any of the actors anymore and the collision was gone… strange stuff

Well, so it seems we have to wait for an update of the engine which will fix that stuff…
It’s not the only issue I have with tracing, a multi box trace doesn’t work at all for me: Multi Box Trace does not work - Blueprint Visual Scripting - Unreal Engine Forums

That’s too bad John, i’ve got the same problem but it doesn’t happen often. My main problem is using Get Hit Result Under Cursor, it happens a lot more (for me) that it returns 0,0,0. I think i’ve tried all possible combinations and nothing works…

You are doing a trace every tick, is it important that every single tick hits the landscape? I mean what if you just try to ignore those blank results or if you get a blank result try to do a second trace with a slightly offset X,Y position as target?

Yes, it is. Think about sending units around in an RTS Game. The player clicks, and nothing happens. He clicks again at the same location, and again nothing happens. The Unit would never move, unless the player is moving the mouse to another location. This is extremely frustrating for the player, isn’t it?

A slightly offset may produce large differences in where the trace hit’s the landscape. Think about a mountain in the foreground and some other stuff in the background. The player might click the edge of a mountain, but if the trace would be 1 pixel to the right, the trace may hit the background.

Okay would you test a trace on click? I think the every tick stuff is the problem( iam doong this in a project myself, dont have that issue) like in the rts example

Hi John,

I no longer have this issue, here’s what i’m doing:

in my HUD BP i update the vectors DeprojectWorldLocation and DeprojectWorldDirection each tick by using Deproject from GetMousePosition.
Then each tick in my playercontroller BP i trace from the DeprojectWorldLocation in DeprojectWorldDirection and every trace (after the first) returns the correct value.

I hope this helps :slight_smile:

I need to do it every tick.

Is there some special thing I have to mind while using deproject? It just returns (0,0,0) for me…

“Get mouse position” works fine.

Deproject is a pretty poorly implemented function. Use the cousin-function “convert screen location to world space”.

Also, FYI, consider swapping the line trace for a sphere/capsule trace with a narrow diameter. If the problem is that a single point doesn’t register the trace, then the sweeping of geometry across that point will automatically catch another nearby point when a slightly wider part of the sphere collides instead.

Thanks, that works, but it doesn’t solve my problem.

Thommie, it doesn’t make any difference whether I do it like you said or like I did it before. I still have the same problem.
Does it really work for you with a landscape? With normal static meshes I also don’t have any problem.

Thanks, that’s a great idea and it works perfectly.

Although, I guess the performance of a sphere or capsule trace will be worse than a single line trace, right? I’m always a a bit cautious with stuff that’s executed every tick. So I think it would be really great if Epic would fix this bug.

Ah i see i made a mistake, i’m updating it from DrawHUD in my HUD BP, not Tick. I believe deproject doesn’t work outside DrawHUD.

Also how are you getting that Get Mouse Position node? Mine needs a Playercontroller to work.

I was going to suggest the trace by sphere thing too.

I wouldn’t worry about performance on that just yet, either. That kind of thing is basic for the engine (it’s doing millions of traces a second on the render as it is). Make sure your trace isn’t going pointlessly far, to be on the safe side though