# Line Trace from cursor widget to world has some deviation

**URL:** <https://forums.unrealengine.com/t/line-trace-from-cursor-widget-to-world-has-some-deviation/434106>\
**Category:** UI\
**Tags:** project-world-locati, unreal-engine, Widget, UE4, question, Blueprint, dpi\
**Created:** [September 19, 2018, 8:30pm UTC](https://forums.unrealengine.com/t/line-trace-from-cursor-widget-to-world-has-some-deviation/434106 "2018-09-19T20:30:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohammmadreza\_h4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mohammmadreza\_h4](https://forums.unrealengine.com/u/mohammmadreza_h4)\
**Post date:** [September 19, 2018, 8:30pm UTC](https://forums.unrealengine.com/t/line-trace-from-cursor-widget-to-world-has-some-deviation/434106/1 "2018-09-19T20:30:46Z")

</div>

Hi  
I’m trying to create a bombard screen for select Bombard Location to do this I create a cursor widget and add in to another widget, like fig 1 and fig 2 I get cursor widget position and send it to my weapon Blueprint, after that like fig 3 I use this position and line trace from cursor to location but the line has large deviation from the Cursor Point (The way in fig 3 work well in select location by touch ) any body know why this happend ?

fig 1 :

 ![254163-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/f/0/8f0c0db10cdb757868f3b917bf14ef064320a360.png)

fig 2 :

 ![254164-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/9/8/d986f6e297b14da394b5c4253f6adefb040d769d.png)

fig 3 :

 ![254165-3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/0/8/d087276fd3e0b2d8c3a56f76c64cdbd0bfaca145.png)

fig 4 :

 ![254166-4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/d/3/5d3032e3546e525320c71941d07ceb356fcf3c47.jpeg)

---

<div class="post-metadata">

**Author:** ![mightyenigma](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mightyenigma](https://forums.unrealengine.com/u/mightyenigma)\
**Post date:** [September 20, 2018, 3:51am UTC](https://forums.unrealengine.com/t/line-trace-from-cursor-widget-to-world-has-some-deviation/434106/2 "2018-09-20T03:51:40Z")

</div>

I don’t know what will fix it. Maybe try changing your CalculatTargetLocation function so the World Direction is not used, you simply add 0,0,-100000 to the Location for the trace end. Does that help?

---

<div class="post-metadata">

**Author:** ![mohammmadreza\_h4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mohammmadreza\_h4](https://forums.unrealengine.com/u/mohammmadreza_h4)\
**Post date:** [September 20, 2018, 5:56am UTC](https://forums.unrealengine.com/t/line-trace-from-cursor-widget-to-world-has-some-deviation/434106/3 "2018-09-20T05:56:40Z")

</div>

no the trace end Directly under the camera point at center of screen.

---

<div class="post-metadata">

**Author:** ![mohammmadreza\_h4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mohammmadreza\_h4](https://forums.unrealengine.com/u/mohammmadreza_h4)\
**Post date:** [September 20, 2018, 7:18am UTC](https://forums.unrealengine.com/t/line-trace-from-cursor-widget-to-world-has-some-deviation/434106/4 "2018-09-20T07:18:43Z")

</div>

I notice that is a Position Problem because when I set **Remove DPIScale** true in **Set Position in Viewport** (fig 5) the Cursor don’t work true but the trace end is true (fig 6)any body know how can fix this ?

fig 5 :

 ![254150-5.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/b/9/3b92ca52d89865cc796a6be73550ab960d11c3ca.png)

fig 6 :

 ![254201-6.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/c/3/0c3a226452bf863b594564ffc889b9612410fef0.jpeg)

---

<div class="post-metadata">

**Author:** ![mightyenigma](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mightyenigma](https://forums.unrealengine.com/u/mightyenigma)\
**Post date:** [September 20, 2018, 9:32pm UTC](https://forums.unrealengine.com/t/line-trace-from-cursor-widget-to-world-has-some-deviation/434106/5 "2018-09-20T21:32:43Z")

</div>

If that’s how it works then maybe you can set a variable to remember the cursor position before removing DPI scale, and use that for your trace instead.

---

<div class="post-metadata">

**Author:** ![mohammmadreza\_h4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mohammmadreza\_h4](https://forums.unrealengine.com/u/mohammmadreza_h4)\
**Post date:** [September 21, 2018, 6:01am UTC](https://forums.unrealengine.com/t/line-trace-from-cursor-widget-to-world-has-some-deviation/434106/6 "2018-09-21T06:01:24Z")

</div>

I set the cursor position in \*\*Cursor position variable \*\* before use set position in view port function ( fig 5) but the problem is when I wand trace, it tracing to position that equal to remove DPI scale from cursor position. The problem has two state in first state if I don,t remove DPI Scale the result is fig 4 and in second state if I Remove DPI Scale the tracing is work well but the cursor go far from the position that I release it fig 6 …

---

<div class="post-metadata">

**Author:** ![mightyenigma](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mightyenigma](https://forums.unrealengine.com/u/mightyenigma)\
**Post date:** [September 22, 2018, 6:43am UTC](https://forums.unrealengine.com/t/line-trace-from-cursor-widget-to-world-has-some-deviation/434106/7 "2018-09-22T06:43:29Z")

</div>

So that is why i was thinking of using two different variables so you can remove dpi scaling for one but not the other

---

<div class="post-metadata">

**Author:** ![mohammmadreza\_h4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mohammmadreza\_h4](https://forums.unrealengine.com/u/mohammmadreza_h4)\
**Post date:** [September 23, 2018, 1:20pm UTC](https://forums.unrealengine.com/t/line-trace-from-cursor-widget-to-world-has-some-deviation/434106/8 "2018-09-23T13:20:40Z")

</div>

I don’t Understand what you mean could you please explain more? there in no node for add or remove dpi scale and the remove dpi scale is only a bool choice in **set position in view port node**.

---

<div class="post-metadata">

**Author:** ![mohammmadreza\_h4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mohammmadreza\_h4](https://forums.unrealengine.com/u/mohammmadreza_h4)\
**Post date:** [September 23, 2018, 2:58pm UTC](https://forums.unrealengine.com/t/line-trace-from-cursor-widget-to-world-has-some-deviation/434106/9 "2018-09-23T14:58:08Z")

</div>

finally found it the problem is the way i get the bombard cursor position ,the true way is like fig 7 :

 ![254525-7.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/7/f/47f4ab2c82a3b202d7e6ba05134d66535f0ffc8e.png)
