I have a third person camera line trace to the centre of my screen for a fixed crosshair (called Dynamic Crosshair in my build because it changes size).
I have a second line trace running from the gun to the centre of the screen for a non-static crosshair that will show the player that their bullet will be blocked by an object in front of them like so (a crosshair will go where the green hit box is)
The bullet line trace input for the end point takes the hit point from the non-static crosshair, then adds a clamped random range based on the character’s speed and stance to adjust accuracy.
Everything works exactly as planned except one thing. The random range affects all three axis, meaning sometimes the line trace falls short of the intended hit marker. (it moves the bullet slightly left, right, up, down, but also forward - not an issue - and back. This is in the picture below
I need to increase the distance of the line trace without affecting any other direction, and I can’t for the life of me work out how.
The start point is the bullet. The end point is the crosshair hitbox + random number multiplier and the random sometimes makes the numbers too short a distance.
edit: To calculate the maximum offset (to use for the scale factor), it’s square root of (3 * MaximumOffsetPerAxis^2). Or just do twice MaximumOffsetPerAxis.
If they are all different, it’s sqrt(x^2+y^2+z^2) where x,y,z are the maximum offsets in each axis. Add 1% extra or something to avoid rounding errors being short.
edit2: This should also work. I added the scale factor using the random offset length.
I’m not sure if I understood the objective correctly though.
Omg because this was the first thing that came to my mind, I was expecting something like it therefore couldn’t really tell what I was looking at in your blueprint code @AlienRenders so didn’t really thought much about it. But today while I was doing something completely irrelevant, this answer of mine randomly came to my mind and I said to myself, hold up… this isn’t right! After thinking for a bit I realized my new answer could be what you already posted, got back to this topic to check and found out that it is! Funnily enough, I already had something similar in use in my own project