x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Line Trace from screen center to world

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 : alt text

Product Version: Not Selected
Tags:
linetrace.jpg (656.8 kB)
more ▼

asked Oct 06 '14 at 11:23 AM in Blueprint Scripting

avatar image

MAlexD
3 1 2 4

avatar image eXi Oct 06 '14 at 11:28 AM

Just a second. I will open up a project to show it to you.

Will post an answer then.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

blueprint

This is what you really want.

blueprint.png (85.3 kB)
more ▼

answered Jul 10 '18 at 02:10 PM

avatar image

Zectbumo54
106 1 8 4

avatar image Nix Dec 24 '18 at 07:37 PM

I suppose this should be the accepted answer. Clean, short, simple and does exactly what you need for aiming.

avatar image Zectbumo54 Dec 25 '18 at 02:20 AM

Thanks, how about an upvote instead?

avatar image eXi Dec 26 '18 at 12:18 AM

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!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Get the camera's location and rotation like so;

alt text

5000 is the distance it fires the trace. You can set it to any distance you like.

linetrace.jpg (62.0 kB)
more ▼

answered Oct 06 '14 at 12:16 PM

avatar image

Jacky
16.7k 671 167 674

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Here, this should work.

I commented it for you:

Picture link: http://puu.sh/c1wg1/58a0679039.png

BP

more ▼

answered Oct 06 '14 at 11:38 AM

avatar image

eXi
6.8k 332 184 465

avatar image MAlexD Oct 06 '14 at 11:58 AM

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 : alt text

linetrace2.jpg (636.8 kB)
avatar image eXi Oct 06 '14 at 12:02 PM

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".

avatar image MAlexD Oct 06 '14 at 12:15 PM

Yeah, it works guy ! As you said, it comes from the Z value.

Thank you guy really !

avatar image eXi Oct 06 '14 at 12:39 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question