Hi, so getting a ball to bounce off a vertical or horizontal wall is easy enough. But now, I'm trying to get a ball to bounce off a circular region (with the appropriate angles/directions). Can someone pleeeease help me with this? I've been banging my head for days trying.
There are two approaches.
1. Continuous collision simulation. This was used by various old WC3 collision systems such as by HINDYhat and such people. This is where you compute the time of collision and then use that to determine the normal to use for angle of reflection (since the surface normal determines how something is reflected).
2. Discrete collision simulation. This is where you detect a collision when one object becomes embedded inside another object. This is basic intersection mathematics (similar to regions which could probably work to simulate it). The normal for reflection is then simply the angle from the collided object to the collider object. The issue with this is that the normal of collision is incorrect due to it taking the end position after a move rather than the point of collision. If movement per tick is small this error will not be noticeable but with high movement per tick it could even reflect through an object off at strange angles.
1. Is the most precise and recommend for small physics situations (I would use it for a sports simulator).
2. Is the fastest and most commonly used due to its speed and simplicity (a lot of commercial games use it) so I would recommend it for ability effects or anything spam-able.
So how does on actually compute 1? Well I am not entirely sure. You are after solving the equation where by the surface equation of a sphere contacts another surface equation of a sphere for the argument t where t defines an offset for the spheres that is dependent on their velocities. If one assumes a constant velocity throughout a tick (I recommend it to avoid excessive integration produced equations) then it should not be too tricky.
But the answer that suits you depends on your understanding of Newtonian physics and how intricate your solution needs to be. So give some detail on how your current system works - bouncing off vertical/horizontal walls. And I'm sure we can find a solution that doesn't increase the scope of your physics more than necessary.