GetHitResultUnderCursor sometimes fails when clicking on landscape

At some specific spots on a landscape I have build the GetHitResultUnderCursor methods fails even though there is landscape under the mouse. By fails I mean resulting in no hit when there obvious should have been a hit. It seems to always be the same spots. I have also checked that I’m not too far away for the hardcoded line tracing length constant.

Version is 4.5.1

Hi ,

How are you calling the “GetHitResultUnderCursor”? Can you show me a screenshot of your blueprint?

I’m just calling GetHitResultUnderCursor(ECC_Visibility, false, Hit); in my custom PlayerController on a binded input event.

Hi ,

I ran some tests on some terrain using GetHitResultUnderCursor and was not able to see it fail anywhere when clicking on the terrain. Are you able to see this happening only in your project, or do you see the same behavior in a new project? Also, are you using the binary version of the Engine, or did you build the Engine from source code?


I get the same problem when I built the engine from source code as when using the binary version. I haven’t tried using another project yet though.

I just wanted to check in and see if you had a to do any additional experimenting with this issue. Have you been able to narrow down when this occurs at all? If you haven’t already done so, are you able to get the newly released version 4.6.0 and try this in that version to see if it still occurs?

I will try it with 4.6 and comeback with the result.

I still have the issue after updating to 4.6.

Hey ,

I’m trying to report this issue internally, but I need a consistent way to reproduce the bug before I can report it. Do you have a set of steps I can follow to reproduce the bug?

I have now made a demo project that should demonstrate the issue. A line is drawn every time the tracing fails. The code is pretty self-explanatory I think. For me it fails from the starting position when you pressed play.

Demo project

I have now provided a demo below.

Thanks . That project makes the bug really easy to see. I’m looking into this, I’ll let you know if I have any updates.

Sounds great. Thanks!

Hey , a few things. While your project is showing the tracing fail, that’s partly because GetHitResultUnderCursor looks for the position of the mouse, not the center of the camera. To see what I mean, move the camera around and then press the Windows key. You’ll see that the mouse isn’t in the center of the viewport, but somewhere else. If you move it outside of the viewport, then there’s no object under the cursor so GetHitResultUnderCursor returns false. That seems to be part of why we’re not seeing hit results.

I tried reproducing the problem in my own project with blueprints, both using line traces based on camera position and using GetHitResultUnderCursor, and I can’t see any traces ‘missing’ the landscape in my projects. I looked through your code and the logic seemed sound (tsk tsk, no comments!), but it’s strange that I can’t reproduce the problem outside of your project.

I realize that I forgot to enable the mouse pointer in the demo. The thing is that I have an other project, my real game. Where this issue exists with the mouse pointer enabled. I will look into it and see if I can update the demo. Sorry for that, was a bit hasty when I made it.

Fixed Demo?

I have now updated the demo so it uses the cursor. I also removed the automatic clicking and immobilized the pawn. I can still get the issue. Try clicking all over the screen and you should soon see it fail somewhere. It seems to always be the same spots.

I have made an update now. See below.

No need. There are still some traces getting through the landscape in your project and not in mine. Investigating that is more important than enabling mouse cursor.

I’m using blueprints for clarity and ease of use; here’s my setup.

My landscape is using default settings (except height), and everything else in the project is blank/default. I’m not entirely sure why we’re seeing different results here.

Edit: The Object Types variable is set to ‘WorldStatic’.

It’s not exactly the same. I’m using the channel version when tracing. I have a blueprint demo now also =) I can get the error in this one too.