I have 2 round objects, A and B. Object A will move towards object B in a bullet behaviour. I want the object A to stop immediately on collision with object B. I am thinking of getting the collision coordinate so that I can set the position of object A. What is the best way to detect this precisely? Or any other approach that's better?
If they are the same size:
Develop games in your browser. Powerful, performant & highly capable.
This might help.
Thanks for the replies!
I tried your expression but it doesn't give the result I want. As in, sometimes it will be off by a few pixels. Does the collision polygon affect the results? The objects are different sizes.
They aren't the same size.
Just use the position the object had on collision....
I tried that but sometimes the ball went further in. I guess it's due to collision polygon. The ball is round but there are only 8 collision points. I am guessing certain collision area is within the ball perimeter and thus it stopped slightly later. Do you have a solution to this? Not sure if adding more than 8 collision points is a good idea but that's the only solution I can think of.
I found the solution. Basically I just use a dummy sprite to get the angle between the two balls and set the position towards that angle. Thanks for the tips guys.