English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I need to know how i should go about handling a collision.
I can detect that the collision has occured, but by stopping the player completly normaly means it looks bad or i get stuck on the object. I need to know how to go about making it Slide across the surface when it collides on a angle, using the objects Vector3 Position, Vector3 Velocity ect...

2007-09-20 13:53:29 · 1 answers · asked by Anonymous in Science & Mathematics Physics

1 answers

OK, assuming round pucks, the collision happens when the distance between centers = r1+r2. At this point, compute the components of preimpact relative velocity VRelPre = V2-V1 perpendicular (VRel[Perp]) and parallel (VRel[Par]) to the line between the centers. Also compute VSystem = (m1V1+m2V2)/(m1+m2). For generality I'm assuming the collision may be partly or totally elastic. Multiply preimpact VRelPre by the coefficient of restitution to obtain postimpact VRelPost. Then model the effect of the bounce, which leaves VRelPost[Perp] the same and changes the sign of VRelPost[Par]. VSystem remains unchanged (cons. of momentum). Postimpact V1 = VSystem - VRelPost*m2/(m1+m2) and V2 = VSystem + VRelPost*m1/(m1+m2).
Since I know nothing about XNA 3D I'll leave the coding to you.

2007-09-22 03:36:12 · answer #1 · answered by kirchwey 7 · 0 0

fedest.com, questions and answers