MAlexD
(MAlexD)
October 6, 2014, 11:23am
1
Hey everybody,
I’m currently doing a small amateur FPS game and I’m doing right now firing system and I would like to trace from my crosshair (Which is in the center of my screen) to the world.
I tried to use the “Convert Mouse Location to World Space” function but it doesn’t work, my linetrace isn’t on my crosshair.
Here is my current script for line trace :
1 Like
eXi
(Cedric Neukirchen)
October 6, 2014, 11:28am
2
Just a second. I will open up a project to show it to you.
Will post an answer then.
MAlexD
(MAlexD)
October 6, 2014, 11:58am
3
Thank you for your answer dude !
It’s almost that !
But look, when I look at the floor, my line trace begin to shift to the bottom, like this :
MAlexD
(MAlexD)
October 6, 2014, 12:15pm
4
Yeah, it works guy !
As you said, it comes from the Z value.
Thank you guy really !
Jacky
(Jacky)
October 6, 2014, 12:16pm
5
Get the camera’s location and rotation like so;
5000 is the distance it fires the trace. You can set it to any distance you like.
eXi
(Cedric Neukirchen)
October 6, 2014, 11:38am
6
Here, this should work.
I commented it for you:
Picture link: http://puu.sh/c1wg1/58a0679039.png
2 Likes
eXi
(Cedric Neukirchen)
October 6, 2014, 12:02pm
7
I guess that’s because the Z value you add is too low.
Look in the components tab at what height your camera is and use this for the Z value instead of “Base Eye Height”.
eXi
(Cedric Neukirchen)
October 6, 2014, 12:39pm
8
Np, would you accept the answer on the left side of the answer with the check mark? So others will see that this question was solved.
This is what you really want.
6 Likes
I suppose this should be the accepted answer. Clean, short, simple and does exactly what you need for aiming.
Zectbumo54
(Zectbumo54)
December 25, 2018, 2:20am
11
Thanks, how about an upvote instead?
eXi
(Cedric Neukirchen)
December 26, 2018, 12:18am
12
4 years ago I was still learning. (: while all answers work, this one here is indeed the better one. I changed the accepted answer. Cheers!
SharkPolo
(SharkPolo)
February 19, 2023, 11:49pm
13
Unreal 5 there is no Get camera location from the FPS project.
Could you remake the example again?
Nawrot
(Nawrot)
February 20, 2023, 6:38am
14
Drag camera component, get its forward vector, get component location in world.