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"

How reduce length of vector create by raycast after a hit

Hi, I made a prototyping of cover with a raycast hit which hit from forward of player to do a move to at this place. The issue is the player move exactly on the hit of raycast, so the character is in the wall/mesh. So i want to reduce the lenght of the vector after hit a wall/mesh to stop the player nexto to the wall/mesh.

Do you know how do that ?

Thanks alt text

Blueprint alt text

Product Version: UE 4.12
Tags:
more ▼

asked Jul 06 '16 at 02:03 PM in Blueprint Scripting

avatar image

yoanlesouder
3 1 2

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

3 answers: sort voted first

Hello yoanlesouder,

After taking a quick look at your question I made up an example that could help you to get pointed in the correct direction. I hope that this information helps.

Example:

In the example below I get the hit location and I then figure out a point that is 100 units from the hit location towards that actor that fired the original line trace. The float value mentioned in the picture below will be what needs to be changed to adjust the distance from the original impact location to the desired distance.

alt text

Make it a great day

covertracehelp.png (215.7 kB)
more ▼

answered Jul 06 '16 at 07:17 PM

avatar image

Rudy Q ♦♦ STAFF
47.3k 545 132 525

avatar image yoanlesouder Jul 06 '16 at 11:11 PM

I use your example Rudy to understand how correct the issue and It's work now. Thanks all for yours answers!

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

yoanlesouder, try using the "Teleport" node to move your player's pawn. It will automatically correct position to account for walls and other obstacles.

more ▼

answered Jul 06 '16 at 02:28 PM

avatar image

Krxtopher
825 27 15 57

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

The issue is that your collision is not set up properly.

Examining the doc for the Location pin of the Break Hit Struct, we can see the following:

alt text

Thus we have a few solutions:

1. Correct the wall and player collision so that the proper location is returned (recommended)

Check the collision on both the wall and the player meshes, and ensure there is ample space to represent the models.

2. As @Krxtopher said, use the Teleport node - it's kind of made for this

3. Offset the return vector along a line originating from the start location

This is basic vector math, something everyone developing a game needs to learn. It is important to note that we are not dealing with traditional vectors, but a structure holding 3 values (X,Y,Z) called Vector3. A vector has a coordinate location and magnitude. Vector3 is simply a 3 space point.

If we have Vector3 A, and we want to find Vector3 C along the line between Vector3 A and Vector3 B. The math for this follows in this math discussion:

http://math.stackexchange.com/questions/155514/how-to-get-point-between-two-points-at-any-specific-distance

Instead of 2 points, x and y, you are dealing with 3.

Good luck and happy mathing :)

more ▼

answered Jul 06 '16 at 04:44 PM

avatar image

Dodgin
351 7 5 32

(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