I found out that the solution doesn’t actually work properly, and it only worked specifically in the tests I’ve conducted with the suspension, which were on a flat surface, I have found a different solution a few days ago but didn’t provide an update, but since it’s possible that people might stumble on this post for the same problem I changed my mind
after digging in godot tutorials for a solution, i couldn’t find one, so instead i looked for a pure math video, and found this:
so from that video i wrote the following function:
func project_vector(from: Vector3, to: Vector3)->Vector3:
return (((from.x * to.x)+(from.y * to.y)+(from.z * to.z))/(sqrt(to.x**2+to.y**2+to.z**2)**2))*to
this function works very nicely, but again it might be only for the tests i conducted