# Need Help with Raycast

**URL:** <https://forums.unrealengine.com/t/need-help-with-raycast/406668>\
**Category:** Cinematics & Media\
**Tags:** raycasting, unreal-engine, question, Blueprint\
**Created:** [October 10, 2017, 5:33pm UTC](https://forums.unrealengine.com/t/need-help-with-raycast/406668 "2017-10-10T17:33:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![a548922](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@a548922](https://forums.unrealengine.com/u/a548922)\
**Post date:** [October 10, 2017, 5:33pm UTC](https://forums.unrealengine.com/t/need-help-with-raycast/406668/1 "2017-10-10T17:33:36Z")

</div>

I am needing to create a Raycast from a fixed camera location that can generate from the mouse location on the view port. Think of it like an Arcade game where you have to create a bullet that spawns from the camera to the location where the mouse is clicked.

This was my unsuccessful attempt:

 ![216266-project-help.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/8/6/f86be5b637023ec8654fd9cb96b221d01cb99520.png)

Any Suggestions or Help?

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [October 10, 2017, 6:39pm UTC](https://forums.unrealengine.com/t/need-help-with-raycast/406668/2 "2017-10-10T18:39:14Z")

</div>

Better use PlayerController - ConvertScreenToWorld. This will be MouseWorldLocation and line trace start.

Then use line trace end = MouseWorldLocation + CameraForwardVector\*TraceDistance

---

<div class="post-metadata">

**Author:** ![a548922](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@a548922](https://forums.unrealengine.com/u/a548922)\
**Post date:** [October 10, 2017, 8:27pm UTC](https://forums.unrealengine.com/t/need-help-with-raycast/406668/3 "2017-10-10T20:27:17Z")

</div>

Will this still use the Camera as the line trace start?

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [October 11, 2017, 6:34am UTC](https://forums.unrealengine.com/t/need-help-with-raycast/406668/4 "2017-10-11T06:34:06Z")

</div>

No, GetPlayerController → ConvertScreenToWorld already uses screen coordinates converted to world.

---

<div class="post-metadata">

**Author:** ![a548922](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@a548922](https://forums.unrealengine.com/u/a548922)\
**Post date:** [October 11, 2017, 2:41pm UTC](https://forums.unrealengine.com/t/need-help-with-raycast/406668/5 "2017-10-11T14:41:36Z")

</div>

![216366-untitled.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/d/0ad1b58c0117741ee0ded1670bfe90cc4ee3180b.jpeg)

Its only going to one location on the screen… What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [October 11, 2017, 3:28pm UTC](https://forums.unrealengine.com/t/need-help-with-raycast/406668/6 "2017-10-11T15:28:47Z")

</div>

Not screen location here. mouse location to world space for start

---

<div class="post-metadata">

**Author:** ![a548922](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@a548922](https://forums.unrealengine.com/u/a548922)\
**Post date:** [October 11, 2017, 3:32pm UTC](https://forums.unrealengine.com/t/need-help-with-raycast/406668/7 "2017-10-11T15:32:47Z")

</div>

I’m sorry I am having trouble with this. Are you able to show me screen shot please?

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [October 11, 2017, 6:08pm UTC](https://forums.unrealengine.com/t/need-help-with-raycast/406668/8 "2017-10-11T18:08:11Z")

</div>

you already have ‘convert mouse location to world’ function in graph. just plug it into trace start.

---

<div class="post-metadata">

**Author:** ![a548922](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@a548922](https://forums.unrealengine.com/u/a548922)\
**Post date:** [October 12, 2017, 3:52am UTC](https://forums.unrealengine.com/t/need-help-with-raycast/406668/9 "2017-10-12T03:52:03Z")

</div>

This is what happens when I click anywhere on the screen:

 ![216428-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/1/4/814b698d30164605b19ef6632677184e9ff323d8.jpeg)

Using:

 ![216429-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/2/e/32eecdc35295a265fc3b1360600b1c1b890c166f.jpeg)

---

<div class="post-metadata">

**Author:** ![redbox](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@redbox](https://forums.unrealengine.com/u/redbox)\
**Post date:** [October 12, 2017, 6:44am UTC](https://forums.unrealengine.com/t/need-help-with-raycast/406668/10 "2017-10-12T06:44:01Z")

</div>

Can’t ou see that you convert (0,0) screen location from that node?

Use mouse location also!

 ![216420-2017-10-12-0941.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/2/3/123255524cf4c1c9f3ed66f68e77e195481d5f9e.jpeg)
