# Convert Mouse Location to World Space seems to be inaccurate?

**URL:** <https://forums.unrealengine.com/t/convert-mouse-location-to-world-space-seems-to-be-inaccurate/487171>\
**Category:** Cinematics & Media\
**Tags:** bug, unreal-engine, top-down, question, build-editor\
**Created:** [August 7, 2021, 7:46pm UTC](https://forums.unrealengine.com/t/convert-mouse-location-to-world-space-seems-to-be-inaccurate/487171 "2021-08-07T19:46:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bionic\_Leaf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bionic\_Leaf](https://forums.unrealengine.com/u/Bionic_Leaf)\
**Post date:** [August 7, 2021, 7:46pm UTC](https://forums.unrealengine.com/t/convert-mouse-location-to-world-space-seems-to-be-inaccurate/487171/1 "2021-08-07T19:46:07Z")

</div>

Wherever my mouse lands, the end of the line trace appears somewhere close nearby, but rarely directly under the mouse (always seems to be a random spot near the mouse, not constantly slightly above and to the left like the example picture).

The trace is detecting a thin box collision placed on the floor of the terrain, which is completely flat. The grid box you can see is only for visuals and has no collision. The box collision is set to block a custom trace channel “Building”, which the terrain ignores.

I created the code in blueprints, the “Actors to Ignore” variable only contains the structures you place to build your base, none of which have been placed in the screenshot.

The camera can rotate around the building area, if the camera’s location/rotation plays a role in how this node works.

 ![345863-2021-08-07-12-36-18-luntproject-unreal-editor1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/f/c/1fc802d574d803c04f7c75100a4df08d754b7dbc.png)

 ![345864-inked2021-08-07-12-32-16-luntproject-preview-netmo.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/5/4/25401d65a71d6f76ef0b7ad3f94503fb50442c3d.jpeg)

---

<div class="post-metadata">

**Author:** ![Bionic\_Leaf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bionic\_Leaf](https://forums.unrealengine.com/u/Bionic_Leaf)\
**Post date:** [August 7, 2021, 7:51pm UTC](https://forums.unrealengine.com/t/convert-mouse-location-to-world-space-seems-to-be-inaccurate/487171/2 "2021-08-07T19:51:05Z")

</div>

Also forgot to mention ^ I tried GetHitResultUnderCursorByChannel as well but it produced the same result

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [August 8, 2021, 5:51am UTC](https://forums.unrealengine.com/t/convert-mouse-location-to-world-space-seems-to-be-inaccurate/487171/3 "2021-08-08T05:51:43Z")

</div>

Clear description of the issue is clear.

* * *

Try it like this:

 ![345856-screenshot-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/c/3/0c3be82711c57f144f0d3b859322076d3eb4b599.png)

The World Location with no direction as Start will not work. The Camera Manager has the world location of the camera we’re looking through.

Here we’d trace from the centre of the screen, where the cam’s frustum originates, towards the mouse cursor projected into the world along the direction.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [August 8, 2021, 6:05am UTC](https://forums.unrealengine.com/t/convert-mouse-location-to-world-space-seems-to-be-inaccurate/487171/4 "2021-08-08T06:05:43Z")

</div>

> detecting a thin box  
> collision placed on the floor of the  
> terrain, which is completely flat.

Here’s a method that does not rely on geometry, making such box redundant (but you may have other uses for it, ofc)

 ![345857-screenshot-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/2/1/2211907bf87bd18c183901307bcba110dcaf8751.png)

Think of this as of a virtual plane positioned at Plane Origin and facing along the Plane Normal. The returned intersection would be the world location where the line hits that plane.

Here’s a visualisation and an example:

> [@Line Trace from a 3d point to mouse location](https://forums.unrealengine.com/t/line-trace-from-a-3d-point-to-mouse-location/237661/3):
>
> You’re tracing with a fixed distance of 500, replacing the projection’s X with a fixed value. It’s actually hard to imagine how that would look like, a strangely distorted / twisted undulating surface mayhaps? cool, for sure. I want this trace to stay on the same plane as my character, so the X value of the start point & end point should be the same. Consider the following: green_circle create a virtual plane where the character is and point it towards X (Plane Normal 1,0,0) …

---

<div class="post-metadata">

**Author:** ![Bionic\_Leaf](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bionic\_Leaf](https://forums.unrealengine.com/u/Bionic_Leaf)\
**Post date:** [August 10, 2021, 12:06am UTC](https://forums.unrealengine.com/t/convert-mouse-location-to-world-space-seems-to-be-inaccurate/487171/5 "2021-08-10T00:06:07Z")

</div>

Thank you for the response! It makes sense, but unfortunately it produces the same problem. It seems to work fine on a different level, however. And yes I have multiple purposes for a box collision but thank you for the second answer!
