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 on left side camera

Is there a way to shoot line trace from camera so they could always be on the left side of the camera? (image exaple below)

hx in advance.

[1]: /storage/temp/234199-linetrace-direction.jpg

Product Version: UE 4.18
Tags:
more ▼

asked Mar 18 '18 at 05:33 PM in Using UE4

avatar image

LordZedd_02
11 2 2 6

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

2 answers: sort voted first

I assume you're doing this in blueprints...

From the Camera component, you want to use the "GetRightVector" node. That will point a vector (of length 1.0) out to the right. Then you just multiply the result by -1.0 to make it point left (or -X, where X is the length you want the vector to be). To do that you want to use the "Vector * float" node.

more ▼

answered Mar 18 '18 at 06:39 PM

avatar image

Jin_VE
4.4k 32 79 42

avatar image LordZedd_02 Mar 18 '18 at 07:30 PM

Thanks Guys! First solution is not working, but the second is (bluepreint below) however not as intended. alt text

But what i'm really trying to accomplish is tracing capsule so it could always be in Y axis of the camera. But why you may ask? Well im trying to implement leaning mechanics and my character is clipping through walls and im trying to find solution for that problem.

What im trying to achive. alt text

Blueprint alt text

avatar image Jin_VE Mar 18 '18 at 07:48 PM

You want to get the right vector, multiply it by -100, and then ADD IT to the world location -- it should go straight from GetWorldLocation into the add, no adding or multiplying anything else. The add should be plugged straight into the End pin of the trace node.

avatar image LordZedd_02 Mar 18 '18 at 08:41 PM

Ok thanks now it works fine.

But still capsule trace would be better, any idea how to trace it so it would always be on Y axis of the camera?

avatar image Jin_VE Mar 18 '18 at 08:55 PM

You can't rotate the capsule trace so it will always be oriented like it is for a character standing up.

But you should be able to get what you want by doing a sphere trace. As it traces along the path, it forms a capsule shape. It's better than a line trace because it considers radius so you will avoid leaning into things more consistently.

avatar image LordZedd_02 Mar 18 '18 at 09:09 PM

Actually im using sphere trace, i guess you cannot rotate it either? alt text

capsule-vector.jpg (334.1 kB)
avatar image Jin_VE Mar 18 '18 at 10:32 PM

A sphere looks the same no matter how it is rotated so there is no control over that. The capsule-like shape that a sphere trace creates is based on the line between start and end.

If the camera is always parallel to the ground then GetRightVector will always give a vector parallel to the ground. That will cause sphere trace to trace a capsule shape parallel to the ground. If you want it to happen on an angle then GetRIghtVector needs to return a vector that isn't parallel to the ground. To do that you would need to either rotate the camera (local X axis) or call GetRIghtVector from a different component (like a bone/socket in the mesh component).

avatar image LordZedd_02 Mar 20 '18 at 05:50 PM

Thanks, it is working!

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

Get player camera manager, from it get camera right vector, then negate it, and this will be camera left vector )

more ▼

answered Mar 18 '18 at 06:03 PM

avatar image

redbox
4.3k 81 19 104

avatar image LordZedd_02 Mar 18 '18 at 06:29 PM

Could you be more specific, im sending bluprint image. I would appreciate it if you could point out what i have been doing wrong.

thx

[1]: /storage/temp/234211-left-trace.jpg

left-trace.jpg (400.5 kB)
avatar image redbox Mar 18 '18 at 06:39 PM

Operation -180 doing wrong things here. Right vector is a normalized direction vector. Use NegateVector operation instead.

Next, if you want to trace on some distance, you must specify it. (TraceDistance = 10000 or something)

CameraWorldLocation + TraceDistance * CameraLeftVector.

(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