Mario Kart Collision Post 3

Collision Response

  • I created a collision manager class that has two functions: checkPhysModelCollisions and collisionDetectionAndResponse

  • checkPhysModelCollisions is a function that takes a vector of all the physModels and checks to see if any of their colliders are intersecting. If they are then a collision struct is added to a vector and returned once all physModels have been checked. This struct contains pointers to the two physmodels intersecting and the normal of the collision.

  • collisionDetectionAndResponse is a function that calls the previous function to get the vector of collisions in that frame. It then loops through this vector and first checks to see if the velocities (v1, v2) are separating by checking if the dot product between (v2- v1) and normal is greater than 0 (aka the Contact Velocity). If true then the velocities are separating and can response code can be skipped. If false then minimum restitution (e) out of the two colliding physmodels is found (currently this is set to 1 as restitution is not currently a parameter in physmodel). The impulse force is then found using impulse=((-(1+e) * conctactVel) / (1 / mass1 + 1 / mass2) * normal. Then v1 = v1 - impulse * 1 / mass1 and v2 = v2 + impulse * 1 / mass2. This function is called every frame.

  • The correct response system took a while to research and create with lots of different permutations on how to get the correct collision response. This included: *Calculating the penetration depth between colliders and moving them apart that much. *Reflecting the velocity using the collision normal *Reducing the physmodels position by their velocity

  • None of these methods worked well and we were unaided by the fact that physmodels were dealing with their own collision responses because they were being applied within the physmodel class.

  • Changing the response system and moving it over to the collision manager greatly improved it.

  • Tweaking of the model’s masses and restitutions is still needed for the responses to be as precise as it can.


Previous
Previous

Mario Kart Item Post 1

Next
Next

Mario Kart Collision Post 2