#How to get distance along a line?
1 messages · Page 1 of 1 (latest)
to get a distance between 2 objects you subtract position of first object from position of second object and then getting a magnitude of the resulting vector
add a subtract chip
connect 2 "get position" chips to it
connect one of get position to the gun and the other to the slide point
connect the output from the subtract chip to the "vector3 get magnitude"
Called Projection
slidee start + (slider direction * Dot(slider direction, target - slider start))
and then u clamp the dot, min being 0 will have the minimum be at the sliders start, negative will allow to go behind the sliders start, positive will allow to go infront the sliders start. And yes its in meters
there are Vector3 Project chips, but you cant clamp it like u can by doing it from scratch unless u use logic or sumn to make it work, but thats dumb
alternatively theres also inverse lerp & lerp. Value is the target, start & end for both inverse lerp & lerp are the same/straight forward
@haughty rover @frigid raptor @marsh bronze
There is a new chip, Closest Point On Line, all you need is to get the closest point on the line and then get the distance from the line origin to closest point on the line, should be 2 chips
but cant clamp
wdym?
i think they said they want for a gun, so needs be clamped
Closest Point On Line Segment, same thing but instead has a length definition
one those pull back things for bullet stuff
Wait, does Vector Project do the same thing?, just getting the magnitude of the projected vector?
ah, either i saw diff thing, or its been updated, or they added another
um
its just the offset itself, not added to slider start
if u really only needed the distance, u would just dot
RR had a certified invention it was just a subtract and a vector3 dot
pretty simple
nah, it is positional if unormalized subtraction
thats what i mentioned first, just i added to slider start bc i assume u need position for a model