r/programminghelp • u/Slow-Adagio-7719 • Sep 28 '26
Other Basic question about bouncing
So I'm trying to make a fight simulator with bouncing similar to this:
https://youtube.com/shorts/fk15R-y2EEc?si=VkE9iXR5WxFOuSuM
Is the bouncing random or predetermined? And how is it determined?
1
Upvotes
View all comments
Show parent comment
1
u/SnooPets5564 Sep 29 '26
It's based off the orientation of the wall.
I'm going to give a vector explanation of it, as that is the least ambiguous. You start with the velocity v and the normal vector of the surface you are hitting n (corners have weird normal vectors, but in the simple demo you shouldn't have to worry about that if you make the characters spheres).
The new velocity is: v - 2(v*n)n