- Hands-On Game Development with WebAssembly
- Rick Battagline
- 123字
- 2021-06-24 13:41:12
Circle collision detection
The most basic kind of collision detection is circle or distance collision detection. If we treat all of our colliders like little circles with a radius and a position, we can calculate the distance between the two locations and see whether that distance is less than the sum of our radii. This form of collision detection is high-speed, but precision is limited. If you look at the projectile in our game, this method works pretty well. Our spaceships, on the other hand, don't fit neatly into a circle. We can adjust the radius of our circle collider on any given ship to give slightly different results. When circle collision detection works, it can be very efficient:
Circle collision hit test