I am having trouble coding collision detection between a single point projectile and numerous irregular polygons. The steps I have taken:
- Used a ray casting algorithm to determine if the projectile will be inside a polygon in the next instance
- Find the closest intersection between the projectile’s vector and all lines in the polygons. This helps to:
- Find the closest line in the projectiles path.
- Run the vector reflection formula with the slope of the line, and resolve the collision
Though I seem to have some problem I can’t solve, the projectile takes a different path depending on its velocity, which it shouldn’t as there is no gravity or friction. It also tends to glitch through certain shapes depending on its velocity.
Code here:
https://github.com/Beluker/Collision
sorry its messy
any help at all is appreciated : D
the projectile is in an array accessible through the console.