Mario Kart Collision Post 3

Mario Kart Collision Post 3

Mar 12, 2019. | By: Evan Diamond
2 mins

The third post in making collision for mario kart in DirectX12

Collision Response

  • I created a collision manager class which has two functions: checkPhysModelCollisions and collisionDetectionAndResponse
  • checkPhysModelCollisions is a function which 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 which 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 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 unaided by the fact that physmodels where dealing with their own collision responses because they were being applied within the physmodel class.

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

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

About

Gamers developing new games.

Social Links

Our Bunker

University of the West of England,
Frenchay Campus, Bristol, BS16 1QY,
United Kingdom.