# GetHitResultUnderCursor sometimes fails when clicking on landscape

**URL:** <https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378>\
**Category:** World Creation\
**Tags:** Raycast, line-trace, unreal-engine, question\
**Created:** [November 19, 2014, 4:49pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378 "2014-11-19T16:49:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [November 19, 2014, 4:49pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/1 "2014-11-19T16:49:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [November 19, 2014, 5:41pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/2 "2014-11-19T17:41:07Z")

</div>

Version is 4.5.1

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b9532c9a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b9532c9a](https://forums.unrealengine.com/u/anonymous_user_b9532c9a)\
**Post date:** [November 20, 2014, 3:28pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/3 "2014-11-20T15:28:59Z")

</div>

Hi ,

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

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [November 20, 2014, 4:56pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/4 "2014-11-20T16:56:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b666e59e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b666e59e](https://forums.unrealengine.com/u/anonymous_user_b666e59e)\
**Post date:** [November 21, 2014, 11:53pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/5 "2014-11-21T23:53:24Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [November 25, 2014, 12:50pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/6 "2014-11-25T12:50:32Z")

</div>

Hi!

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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b666e59e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b666e59e](https://forums.unrealengine.com/u/anonymous_user_b666e59e)\
**Post date:** [December 4, 2014, 3:49pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/7 "2014-12-04T15:49:20Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [December 4, 2014, 11:00pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/8 "2014-12-04T23:00:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [December 14, 2014, 6:31pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/9 "2014-12-14T18:31:22Z")

</div>

I still have the issue after updating to 4.6.

---

<div class="post-metadata">

**Author:** ![Jonathan\_Dorman\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jonathan\_Dorman\_1](https://forums.unrealengine.com/u/Jonathan_Dorman_1)\
**Post date:** [December 15, 2014, 6:25pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/10 "2014-12-15T18:25:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [December 16, 2014, 2:12pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/11 "2014-12-16T14:12:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [December 16, 2014, 4:19pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/12 "2014-12-16T16:19:24Z")

</div>

I have now provided a demo below.

---

<div class="post-metadata">

**Author:** ![Jonathan\_Dorman\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jonathan\_Dorman\_1](https://forums.unrealengine.com/u/Jonathan_Dorman_1)\
**Post date:** [December 18, 2014, 3:41pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/13 "2014-12-18T15:41:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [December 19, 2014, 11:46am UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/14 "2014-12-19T11:46:58Z")

</div>

Sounds great. Thanks!

---

<div class="post-metadata">

**Author:** ![Jonathan\_Dorman\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jonathan\_Dorman\_1](https://forums.unrealengine.com/u/Jonathan_Dorman_1)\
**Post date:** [December 19, 2014, 4:58pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/15 "2014-12-19T16:58:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [December 19, 2014, 5:25pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/16 "2014-12-19T17:25:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jonathan\_Dorman\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jonathan\_Dorman\_1](https://forums.unrealengine.com/u/Jonathan_Dorman_1)\
**Post date:** [December 19, 2014, 5:53pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/17 "2014-12-19T17:53:03Z")

</div>

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.

 ![24508-trace_test_bp.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/4/3/243d5ad6c2e349945107895f8869d2c21ede7dc9.png)

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’.

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [December 19, 2014, 5:56pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/18 "2014-12-19T17:56:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [December 19, 2014, 5:56pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/19 "2014-12-19T17:56:23Z")

</div>

I have made an update now. See below.

---

<div class="post-metadata">

**Author:** ![undercover](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@undercover](https://forums.unrealengine.com/u/undercover)\
**Post date:** [December 19, 2014, 6:23pm UTC](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378/20 "2014-12-19T18:23:24Z")

</div>

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.

[Next page](https://forums.unrealengine.com/t/gethitresultundercursor-sometimes-fails-when-clicking-on-landscape/299378.md?page=2)
