Convert Mouse Location to World Space seems to be inaccurate?

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.

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

Clear description of the issue is clear.


Try it like this:

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.

1 Like

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)

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:

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!