I’m trying to make it so that a normal vector (originally a player’s aim vector) will point down some more according to the distance between that player’s shoot pos and the point that a trace hits, but I can’t find the correct formula.
Your question is incredibly vague. What do you mean by “point down some”, and how does it relate to the distance between the player and the position of his trace hit?
Here’s what I’m trying to achieve. The distance between the player’s muzzle and where he’s looking at is greater (represented as the dotted lines) on the left, so there’s a beam(the bold line) that “points down”. On the other side, the beam is almost entirely straight because the distance is minimal. I apologize for the poor quality, currently I’m using a touchpad and microsoft paint was the only tool available to me at the time I made this.
Hopefuly this time I was more coherent.
What’s the player’s muzzle? I’m still confused from this explanation.
Can you also show your code?
The muzzle of his weapon. The code is on my other computer which isn’t available right now.
[lua]local maxDistance = 128;
local trace = pl:GetEyeTrace();
local distance = trace.HitPos:Distance( trace.StartPos );
local fraction = math.Clamp( distance / maxDistance, 0, 1 );
local normal = LerpVector( fraction, trace.Normal, Vector( 0, 0, -1 ) );
Should do what you want.
Thank you. I’ll try it out later.