I’m making a rolling-ball type game, and I can’t seem to get my sphere-mesh collision code working properly. Currently what I have for the main loop (in regards to collision) is the following: Calculate player acceleration based on input Clamp velocity to avoid clipping Add velocity to position Add acceleration to velocity For each solid object: Check for collision for this object and resolve (how I do this is below) If there were any collisions: Normalize accumulated normal vector (explained below) Slow down ball to account for friction I tried two main methods for resolving collisions, each with their own problems. The first method: For each triangle: If there is a collision: Correct player velocity along normal based on distance Accumulate normal for friction calculations later If velocity perpendicular to surface is above threshold: Rebound ball off surface with damping factor Otherwise, if moving toward surface instead of away: Clear perpendicular velocity The problem with this method is, when I hit a wall, the player will begin to bounce erratically. The collision I’m using to test this looks like this: The second method is similar to the first: Set collision distance accumulator to arbitrarily high value Set triangle index to -1 (to denote that there’s no collisions) For each triangle: If there is a collision: Calculate collision distance If this distance is smaller than the accumulator value: Set triangle index to current triangle Set collision distance accumulator to current distance value If the index is not -1 (there was a… [Read full story]

## Leave a Reply