I am creating a shooting game that recquires precise physics in order to: get precise position of the bullet when it Touches something; final position always at the same place(roblox doesn't do this :/); apply wind factor correctly and even calculate trajectory with collisions beforehand to apply replays. I am actually using raycast on velocity direction to calculate where i should set the bullet position and then I apply collision using this code here:
function reflectVector(vector,surf,bounce)
bounce=bounce+1
return vector-(bounce*vector:Dot(surf)*surf)
end
Surf is a Vector3 from the Raycast.Normal.
vector is a Vector3 of the velocity of the ball.
Bounce is how much the ball bounces (0=no bounce, just slides; 1=Bounce with about the same force).
It's doing great most times (Example1,Example2,Example3), but in some ocasions the ball just don't collide, and I think it's because it only checks one collision with raycast per frame, like when the bullet is rolling on the ground, and then finds a wall, but checks the ground first and ignores the wall, just phasing through it. I would like to know if someone might tell me some math to calculate multiple collisions, I was thinking of making multiple rays and getting each reflectVector function from them but then I don't know what to do next.
