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

97337-pictureexplication.jpg

Blueprint

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

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:

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:

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

Good luck and happy mathing :slight_smile:

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.

Make it a great day

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