# How to shoot ray in specific direction? Top-down shooter

**URL:** <https://forums.unrealengine.com/t/how-to-shoot-ray-in-specific-direction-top-down-shooter/455963>\
**Category:** Community & Industry Discussion\
**Tags:** Raycast, shooting, topdown, unreal-engine, question\
**Created:** [September 25, 2019, 6:01pm UTC](https://forums.unrealengine.com/t/how-to-shoot-ray-in-specific-direction-top-down-shooter/455963 "2019-09-25T18:01:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![carrpenoctem](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@carrpenoctem](https://forums.unrealengine.com/u/carrpenoctem)\
**Post date:** [September 25, 2019, 6:01pm UTC](https://forums.unrealengine.com/t/how-to-shoot-ray-in-specific-direction-top-down-shooter/455963/1 "2019-09-25T18:01:37Z")

</div>

I’m trying to draw a debug line of certain length starting at my pawn position and moving in direction of mouse click, but I keep getting really weird results. Sometimes it works, but mostly does not. Seems like it depends on my character’s location.

 ![288364-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/d/b/5dba9d8c4f5720a8c10069a5e40a20f21b08158a.jpeg)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [September 26, 2019, 10:49am UTC](https://forums.unrealengine.com/t/how-to-shoot-ray-in-specific-direction-top-down-shooter/455963/2 "2019-09-26T10:49:52Z")

</div>

Can you show the code for the line trace?

---

<div class="post-metadata">

**Author:** ![carrpenoctem](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@carrpenoctem](https://forums.unrealengine.com/u/carrpenoctem)\
**Post date:** [September 26, 2019, 10:53am UTC](https://forums.unrealengine.com/t/how-to-shoot-ray-in-specific-direction-top-down-shooter/455963/3 "2019-09-26T10:53:54Z")

</div>

yes, first attachment

 ![288363-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/4/9/84944157bf90d98e30b34547ad2dffd8fa40397f.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [September 26, 2019, 11:11am UTC](https://forums.unrealengine.com/t/how-to-shoot-ray-in-specific-direction-top-down-shooter/455963/4 "2019-09-26T11:11:54Z")

</div>

This works perfectly:

 ![288432-trace.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/9/7/397ef2620d00e60eb7e2d314b1d86bd3b6789cd6.jpeg)

What I think you may be having a problem with, is the difference between the crosshair and the mouse cursor. To see the mouse cursor during gameplay, you have to type ‘SHIFT F1’.
