# Line trace from character towards the mouse location in a 3D space

**URL:** <https://forums.unrealengine.com/t/line-trace-from-character-towards-the-mouse-location-in-a-3d-space/451710>\
**Category:** Blueprint\
**Tags:** unreal-engine, UE4, question, Blueprint\
**Created:** [July 4, 2019, 3:38pm UTC](https://forums.unrealengine.com/t/line-trace-from-character-towards-the-mouse-location-in-a-3d-space/451710 "2019-07-04T15:38:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_25fb4f66](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_25fb4f66](https://forums.unrealengine.com/u/anonymous_user_25fb4f66)\
**Post date:** [July 4, 2019, 3:38pm UTC](https://forums.unrealengine.com/t/line-trace-from-character-towards-the-mouse-location-in-a-3d-space/451710/1 "2019-07-04T15:38:24Z")

</div>

Hey UE4 users 😃

I’m currently using the 3rd person template and I’m trying to trace a line from my character to the mouse position in a 3D space but I’m stuck because I can’t seem to be able to get the X, Y and Z of the mouse in a 3D space.

I’ve tried a few options with the ConvertMouseLocationToWorldSpace node but they only work for a sidescroller game(2D).

Do you have any ideas about how I could achieve this?

---

<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:** [July 4, 2019, 5:37pm UTC](https://forums.unrealengine.com/t/line-trace-from-character-towards-the-mouse-location-in-a-3d-space/451710/2 "2019-07-04T17:37:52Z")

</div>

> I’ve tried a few options with the  
> ConvertMouseLocationToWorldSpace node  
> but they only work for a sidescroller  
> game(2D).

It should work for everything. Generally speaking, it’s this:

 ![281473-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/0/6/006fadef8c6c61f9ff9047e26813ed688f6a483d.png)

Not accounting for world collision since you did not mention any.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_25fb4f66](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_25fb4f66](https://forums.unrealengine.com/u/anonymous_user_25fb4f66)\
**Post date:** [July 4, 2019, 6:11pm UTC](https://forums.unrealengine.com/t/line-trace-from-character-towards-the-mouse-location-in-a-3d-space/451710/3 "2019-07-04T18:11:11Z")

</div>

Hey, thx for taking the time to help me. I took a break and went for some fresh air, came back to the simplest solution I could think of, and it kinda works. I’m thinking of actually showing how I did it so maybe others who struggle with this will have an idea. Also, I’m kinda new to this, should I mark it as solved or should I delete it?

 ![281457-screenshot-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/6/4/064cd7c04495f0ebc86fcca45c6c60cb2dcbf7bd.png)

 ![281458-screenshot-2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/e/b/eeb0716722eef9c936542fb117857efcb4902286.png)

 ![281459-screenshot-3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/a/5/ea532a112eaf35882a192b06b6243a172d2cf886.jpeg)

---

<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:** [July 4, 2019, 6:33pm UTC](https://forums.unrealengine.com/t/line-trace-from-character-towards-the-mouse-location-in-a-3d-space/451710/4 "2019-07-04T18:33:37Z")

</div>

There’s usually more than one solution to each problem, don’t delete it. Someone will find it useful one day.

Good luck with the rest.
