Hiya, I'm wondering how to make a ball fall in a hole when viewed from above.
Say the ball is rolling towards the hole and may go right in, miss totally or roll over the edge a bit.
So I thought about:
a) monitoring a single pixel in the middle of the ball (representing the bottom centre of the ball) and doing a pixel perfect collision with the hole and saying that when they collide, the bottom of the ball is over the hole and thus it's in. But this wouldn't be very realistic as the ball still needs to move to the centre of the hole (i.e. off the rim). To make things simple I could completely HALT the ball (to avoid having to program it skipping out of the hole if the speed is too great) and then set it's speed/direction up to point to the middle of the hole. I could do this by looking at the dx and dy from the centre of the ball to the centre of the hole.
b) monitor a ring of pixels round the edge of the ball. The when they are all over the hole, make it fall it. However, this may lead to the ball rolling across a rim and not going in because some outer pixels were not over the hole even though the middle centre of the ball was clearly over the hole. So this would feel like bad collision detection. Not sure about this one.
Any other ideas? Thanks in advance :-)
Say the ball is rolling towards the hole and may go right in, miss totally or roll over the edge a bit.
So I thought about:
a) monitoring a single pixel in the middle of the ball (representing the bottom centre of the ball) and doing a pixel perfect collision with the hole and saying that when they collide, the bottom of the ball is over the hole and thus it's in. But this wouldn't be very realistic as the ball still needs to move to the centre of the hole (i.e. off the rim). To make things simple I could completely HALT the ball (to avoid having to program it skipping out of the hole if the speed is too great) and then set it's speed/direction up to point to the middle of the hole. I could do this by looking at the dx and dy from the centre of the ball to the centre of the hole.
b) monitor a ring of pixels round the edge of the ball. The when they are all over the hole, make it fall it. However, this may lead to the ball rolling across a rim and not going in because some outer pixels were not over the hole even though the middle centre of the ball was clearly over the hole. So this would feel like bad collision detection. Not sure about this one.
Any other ideas? Thanks in advance :-)